sum numbers in first column of a file
$ cat filename | awk 'BEGIN { tot=0 } { tot+=$1 } END { print tot }'
only print certain lines in a file, eq 20 - 30
$ sed -n -e 20,30p filename
Search all files in and below for a string xyz:
$ find . -exec egrep xyz {} \; -print
Remove all files name ".log.tmp"
$ find . -name .log.tmp -exec rm {} \;
search a file for any of three strings:
$ egrep 'abc|xyz|or' filename
A unique blog for Unix, Linux based Tips, tricks and Shell Scripts. This is intended to be one-stop Information Center for all your Unix, Linux needs.
Showing posts with label one liner. Show all posts
Showing posts with label one liner. Show all posts
Wednesday, June 9, 2010
Wednesday, September 17, 2008
ELIMINATING MULTIPLE SPACES
Here is a simple script whichhelps in eliminating multiplespaces when one wants toextract a particular columnin a set of records from afile.
Here is an example to provethe same:
ps -u $LOGNAME tr -s " " : cut -d: -f
The above script line can beused to extract a column fromthe output of a ps command for a particular user ($LOGNAME).
Here is an example to provethe same:
ps -u $LOGNAME tr -s " " : cut -d: -f
The above script line can beused to extract a column fromthe output of a ps command for a particular user ($LOGNAME).
Labels:
eleminating,
one liner,
Shell Script,
tr
Subscribe to:
Comments (Atom)