Connecting Tech Pros Worldwide Forums | Help | Site Map

question about about Bourne Shell programming

Newbie
 
Join Date: Mar 2008
Posts: 9
#1: Apr 1 '08
I would like to know what does the code below do

#!/cs/local/bin/sh
(cat $1; cat $2) | sort -r | uniq -d | cut -f1,4

can anybody explain it to me

kaarthikeyapreyan's Avatar
Member
 
Join Date: Apr 2007
Location: India
Posts: 101
#2: Apr 1 '08

re: question about about Bourne Shell programming


Quote:

Originally Posted by thungmail

I would like to know what does the code below do

#!/cs/local/bin/sh
(cat $1; cat $2) | sort -r | uniq -d | cut -f1,4

can anybody explain it to me

This code gets two file names from the command prompt
if the contents in your file $1(first arg) and $2(second arg) contains numerals or alphabets or alphanumerals they would be sorted in a reverse order listing all the lines without repetition and cut the fields 1-4 from the output(perhaps all the lines would be printed cause no delimiter is specified)
gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#3: Apr 2 '08

re: question about about Bourne Shell programming


Quote:

Originally Posted by thungmail

I would like to know what does the code below do

#!/cs/local/bin/sh
(cat $1; cat $2) | sort -r | uniq -d | cut -f1,4

can anybody explain it to me


Whenever i encounter a command like this, i would break it into different commands and then see what every command does.



Raghuram
Reply


Similar Unix / Linux / BSD bytes