Que :What is the output of this command? $who | sort –logfile > newfile
Ans : In this command, the output from the command “who” becomes the input to the “sort” command. At the same time, “sort” opens logfile, arranges it together with the output from the command “who”, and places the final sorted output to the file newfile.
Que :Write a command that will find all text files in a directory such that it does not contain the word “amazing” in any form (that is, it must include the words Amazing, AMAZING, or aMAZINg)
Ans : grep –vi amazing *.txt
v---- this option is used to print the non-matching line
i---is used for ignoring case .
*.txt ---this shows all the files which ends with txt.
Que : Write a command that will output the sorted contents of a file named IN.TXT and place the output in another file named OUT.TXT, while at the same time excluding duplicate entries.
Ans : sort IN.TXT | uniq > OUT.TXT
Que : What needs to be done before you can run a shell script from the command line prompt?
You need to make the shell script executable using the UNIX chmod command.
This chmod command makes the shell script file "example1" executable for the user (owner) only:
$ chmod u+x example1
this syntax makes it executable for all (everyone):
$ chmod a+x example1
You can optionally use octal notation to set UNIX permissions using the chmod command (e.g., $ chmod 755 example1). This topic is beyond the scope of this article, but you can find more information by entering "unix file permissions chmod numeric notation" in your favorite search engine.
Ans : In this command, the output from the command “who” becomes the input to the “sort” command. At the same time, “sort” opens logfile, arranges it together with the output from the command “who”, and places the final sorted output to the file newfile.
Que :Write a command that will find all text files in a directory such that it does not contain the word “amazing” in any form (that is, it must include the words Amazing, AMAZING, or aMAZINg)
Ans : grep –vi amazing *.txt
v---- this option is used to print the non-matching line
i---is used for ignoring case .
*.txt ---this shows all the files which ends with txt.
Que : Write a command that will output the sorted contents of a file named IN.TXT and place the output in another file named OUT.TXT, while at the same time excluding duplicate entries.
Ans : sort IN.TXT | uniq > OUT.TXT
Que : What needs to be done before you can run a shell script from the command line prompt?
You need to make the shell script executable using the UNIX chmod command.
This chmod command makes the shell script file "example1" executable for the user (owner) only:
$ chmod u+x example1
this syntax makes it executable for all (everyone):
$ chmod a+x example1
You can optionally use octal notation to set UNIX permissions using the chmod command (e.g., $ chmod 755 example1). This topic is beyond the scope of this article, but you can find more information by entering "unix file permissions chmod numeric notation" in your favorite search engine.
No comments:
Post a Comment