Linux Tips: Difference between revisions
Jump to navigation
Jump to search
m (Created page with "* if you want to send a job on a computer and logout without killing the job: :> nohup ./job") |
mNo edit summary |
||
Line 1: | Line 1: | ||
==Handling jobs== | |||
* if you want to send a job on a computer and logout without killing the job: | * if you want to send a job on a computer and logout without killing the job: | ||
:> nohup ./job | :> nohup ./job | ||
==working with zip files== | |||
Linux usually provides a couple of command piping gzip | |||
zgreg, zcat, zdiff, zless, zmore, zegrep,... | |||
Here is a simple extension of tail and head for zipped files, that you can call ztail and zhead (example is for tail, replace "tail" with "head" everywhere to get zhead) and add to your own /bin directory: | |||
<source lang="bash"> | |||
#!/bin/bash | |||
PATH=${GZIP_BINDIR-'/bin'}:$PATH | |||
usage="Usage: $0 [OPTIONS]... [FILES]... | |||
Like 'tail', but operate on the uncompressed contents of any compressed FILEs. | |||
Options are the same as for 'tail'." | |||
case $1 in | |||
--help) exec echo "$usage";; | |||
-h) exec echo "$usage";; | |||
esac | |||
options="" | |||
files="" | |||
for i in $@; do | |||
str="$i" | |||
if test -f $i && [ ${str:(-3)} = ".gz" ]; then | |||
files=$files"$i " | |||
else | |||
if [ ${str:0:1} = "-" ] && [ $str != "-v" ] && [ $str != "--verbose" ]; then | |||
options=$options"$i " | |||
elif [ $str != "-v" ] && [ $str != "--verbose" ]; then | |||
echo -ne "***Warning: $i is neither a regular zip file or a regular option***\n\n" | |||
fi | |||
fi | |||
done | |||
for file in $files; do | |||
echo "==>"$file"<==" | |||
exec gzip -cd $file | tail $options | |||
done | |||
</source> |
Revision as of 11:13, 11 February 2011
Handling jobs
- if you want to send a job on a computer and logout without killing the job:
:> nohup ./job
working with zip files
Linux usually provides a couple of command piping gzip
zgreg, zcat, zdiff, zless, zmore, zegrep,...
Here is a simple extension of tail and head for zipped files, that you can call ztail and zhead (example is for tail, replace "tail" with "head" everywhere to get zhead) and add to your own /bin directory: <source lang="bash">
- !/bin/bash
PATH=${GZIP_BINDIR-'/bin'}:$PATH
usage="Usage: $0 [OPTIONS]... [FILES]... Like 'tail', but operate on the uncompressed contents of any compressed FILEs.
Options are the same as for 'tail'."
case $1 in --help) exec echo "$usage";; -h) exec echo "$usage";; esac
options="" files="" for i in $@; do str="$i" if test -f $i && [ ${str:(-3)} = ".gz" ]; then
files=$files"$i "
else
if [ ${str:0:1} = "-" ] && [ $str != "-v" ] && [ $str != "--verbose" ]; then options=$options"$i " elif [ $str != "-v" ] && [ $str != "--verbose" ]; then echo -ne "***Warning: $i is neither a regular zip file or a regular option***\n\n" fi
fi done
for file in $files; do
echo "==>"$file"<==" exec gzip -cd $file | tail $options
done </source>