unix
awk passing in a parameter using solaris / sunos
Submitted by admin on Fri, 02/03/2012 - 14:39
take this file , new_list.csv and you wish to see only column 2 with values 14
Tokyo1,3
Tokyo1,3
Tokyo1,3
Tokyo1,3
Tokyo1,3
Tokyo1,3
Tokyo1,3
LONDON1,14
LONDON2,14
LONDON3,14
LONDON4,14
LONDON5,14
LONDON6,14
PARIS1,14
PARIS2,14
PARIS3,14
count=14
Using Solaris
awk -vcount=$count -F"," ' ( $2 == '"$count"' ) { print $1 }' new_list.csv
outputs these values
LONDON1,14
LONDON2,14
LONDON3,14
LONDON4,14
LONDON5,14
LONDON6,14
PARIS1,14
PARIS2,14
PARIS3,14
Using Linux , use without quotes around the variable count. like below;
- admin's blog
- Login or register to post comments
- Read more
list all files that have been modified today
Submitted by admin on Tue, 10/19/2010 - 07:36find ./foundry_*SCRIPTED09* -type f -mtime -1 -print
Unix move files older than 7 days
Submitted by admin on Tue, 10/19/2010 - 07:34find . -type f -name "*.caf" -mtime +7 -exec mv {} backup/ \;
- admin's blog
- Login or register to post comments
Advantages of Linux
Submitted by GeorgeS on Tue, 03/03/2009 - 18:02Large repositories from which you can freely download high quality software for almost any task you can think of.
- GeorgeS's blog
- Login or register to post comments
- Read more
nawk unix tool
Submitted by GeorgeS on Thu, 02/05/2009 - 14:06Awk Utility Awk scans a file (or input) line by line, from the last line, searching for lines that match a specified pattern and performing selected actions ( enclosed in curly braces) on those lines.
%nawk 'pattern' filename
%nawk '{action}' filename
%nawk 'pattern {action}' filename
-- if the regular expression z is matched anywhere on the line, awk prints the entire line.
nawk -F: '/z/' file.txt
-- if the line begins with one or more upper or lowercase letter a's, the entire line is printed.
nawk '/^[Aa]+/' file.txt
- GeorgeS's blog
- Login or register to post comments
- Read more