Uploaded by Tanmay

Linux Commands Part 2

advertisement
Linux Commands Part-2 :1.)wc:- Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. A word is a non-zero-length sequence of
characters delimited by white space.
[wc -l]: Print the newline counts.
[wc -c]: Print the byte counts.
[wc -w]: Print the word counts.
2) Sort-: Sort lines of text files. Write sorted concatenation of all FILE(s) to
standard output. With no FILE, or when FILE is -, read standard input.
[sort filename]: Sort the content of file line by line by in lexicographical
manner, considering ascii characters the base.
[sort file1 file2]: Sort more than one file at once.
[sort -u file1]: To get the unique content in sorted manner.
[sort -m file1 file2]: To merge sort the file content of two already sorted
files.
[sort - file1]: Sort the content of file1+ input from user.
[sort -o result file1]: To save the output of sorted content (overwrites).
[sort - r]: To print in reverse order.
3) cut-: Print selected parts of lines from each FILE to standard output. With no
FILE, or when FILE is -, read standard input.
[cut -f]: Select only these fields; also print any line that contains no
delimiter character, unless the -s option is specified.
[cut -f columns-range -d "delimiter-sign"]: To specify the delimiter
used for seperations in columns.
4) head-: Print the first 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With no FILE,
or when FILE is -, read standard input.
[head -n]: Print the first NUM lines instead of the first 10; with the
leading '-', print all but the last NUM lines of each file.
5) tail -: Print the last 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With no FILE,
or when FILE is -, read standard input.
[tail -n]: Output the last NUM lines, instead of the last 10; or use -n
+NUM to output starting with line NUM.
5) grep -: grep searches for PATTERNS in each FILE.
[grep text file]: Text is searched from file.
[grep text file1 file2]: Text is searched multiples files.
[grep [Rr]ain filename]: It is used to check the presence of Rain and rain
both in filename.
[grep [aeiou]* filename]: It is used to check the presence of words which
start with vowel.
Assignment:1. Merge and sort the contents of File a,File b,File c, and
display the sorted output on the screen.
2. Create Database with Name,Age,Address and Phone
No, seperated by space.
3. Extract Address from the Database.
4. Merge the content of the file, with the input supplied
from the keyboard and sotre the sorted output in the File
f2.
5. Create one file English, that is consisting of words and
display all lines the occurances of that specified word(Eg:
Rain,rain,RAIN,etc.)(Don't use -i in it).
6. Search all lines in a file which ends with a semi colon.
7. Search all lines in a file which donot end with a semi
colon.
Download