Linux Ex
Linux Ex
.. it will redirect to output file cut removes section from each lines of files Syntax: cut [opt] [file] example: cut -c 5 file.txt It display 5rd character from each lines of file. Tr Translate, squeeze, and/or delete characters tr [option] [set1][set2] fmt Reformat paragraph text or simple optimal text formatter fmt [option][file] yes output a string repeatedly until killed syntax: yes [string] tee The `tee' command copies standard input to standard output and also to any files given as arguments. This is useful when you want not only to send some data down a pipe, but also to save a copy. Synopsis: tee [OPTION]... [FILE]... If a file being written to does not already exist, it is created. If a file being written to already exists, the data it previously contained is overwritten unless the `-a' option is used. alias useful to make short name of commands syntax: alias command='shortname for command' example: alias clear='cl' history Display all commands used by user .
LINUX OS ASSIGNMENT
1. For find a file below command $find/ -name version 2. we have to just open that file in VI editor and in a command mod we have to write :%s/data is /data are the other option is sed's/data is/data are/g'/assignment/data_source.txt syntax for sed is Seds/<old string>/<new string>/g<file name> 3. For word count wc -w /assignment/data_source 4. For merging of content of two files use :cat file1.txt file2.txt > file3.txt The uniq command is used for find and omit repeated entries . 5. Here we can use tr command tr - : < customers filename or open that file in Vi editor and :%s/-/; 6. To search through subdirectories we can add -r or -R option it will read all files recursively . 7. The command is ls -l | more. 8. For Compare comm salary salary1 diff salary salary1 9. tr -d difficult < motivate
10. command is ps-A to list all process. 11. The Command is wc w | grep v {a,e,i,o,u} /usr/dict/words 12. For 5*6 matrix yes 1 0| fmt -10 | head -5 13. for find a file with .conf extension we can use ls -lSr /etc/*.conf | head -5 14. in first command it will pipe the output of the ls command and in second it will first create temp file and gives all the ls information to temp file and then it takes the output from it using head command .
for /etc and other directories we can't perform it . There is a permission denied message comes to picture . Because we have now write permission for /etc directories and other directories. 15. (date ; ls) > temp transfer contain of date first and ls second into temp file (date & ls) > temp here date & process is in background (when it will 'done' then after date will be printed in temp), but before that the program jump to ls > temp. here date& -> done process is very quick therefore it displayed first. 16. (1) find . -type f -exec ls -s {} \; | sort -n -r | head -50 | cat -n |tee /tmp/bigfiles.list\ find command will find regular file and using ls-s list all file with details sort will sort the output of find to string numeric value in reverse order tee is like a cat command it will append the data... (2) ls -lrt | cut -c44 it gives the list of file with the size of each file and sorted in the descending order which modified last . (3) grep -i -v Windows *.txt it help to find the text within the file in any text file (4)grep -v "^#" pgm.s ^ perform the starting of the line. It will find the file which start with # in file pgm.s 17. comamand : head -20 somefile.txt | tail -5 18. command for get columns from 20 to 23 of somefile.txt is cut -c20,23 somefile.txt 19. (1) First of all to make directory mkdir sunbeams (2) For rainbow to read and write ls l sunbeams drwxrw-rw- rainbow (3) For tulip to do anything ls l sunbeams drwxrwxrwx tulip (4) For Marigold to only view(read) ls l sunbeams drwxr--r-- mariglod (5) For Raindrops to read and execute ls -l sunbeams drwxr-xr-x raindrops