Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Create a bash shell script to sort and then
uniq the file from the command line & store it to a new
file and output the results to the screen. Name this
script "sortAndUniq.sh"

Answer Posted / vipul dalwala

$1 is the filename u are passing from commnadline

i.e. sh sortAndUniq.sh filename.txt

So $1 = filename.txt

All the commnadline parameters passed to the script are get
stored in $1 , $2, $3....

For example : sh sortAndUniq.sh filename1.txt filename2.txt
filename3.txt

Then $1 = filename1.txt , $2 = filename2.txt , $3 =
filename3.txt

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between scripting and coding?

1048


Is shell scripting difficult?

963


I have 2 files and I want to print the records which are common to both.

1167


What are script files?

1040


Given a file find the count of lines containing the word "abc".

1562


How are shells born?

976


What is shift command in shell script?

1047


How to print pid of the current shell?

1005


How do I set bash as default shell mac?

1018


Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

1521


How to find duplicate record in file using shell script?

1414


How do I run a shell script in powershell?

1141


Why is shell scripting important?

1050


In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?

1157


What is scripting used for?

1052