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

c program to display the information of given file similar to givan by the unix or linux command ls -l

1691


How would you compare the strings in a shell script?

543


What is shell and shell script?

556


I want to connect to a remote server and execute some commands, how can I achieve this?

570


Suppose you execute a command using exec, what will be the status of your current process in the shell?

574






What is sudo command?

548


Is powershell a language?

561


write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?

3587


How do I run a powershell script?

573


What are the zombie processes?

563


What is bash command used for?

579


What is k shell?

532


How to print all the arguments provided to the script?

551


write a shell script to emulate the Id command of PRIMOS which lists files and directories. It list files first with a header FILES and then directories with a header DIRECTORIES. This command has several options. The main ones are. -file select files only -dir select directories only -reverse sort in reverse order -no_header put no header on the output -brief output the header only -size display the size of each file -help display Id´s syntax and options.

2226


How to print the first array element?

550