linux_ex

Upload: mayank-chauhan

Post on 05-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 linux_ex

    1/3

    Commands

    col

    it is like cat command .. it will redirect to output file

    cut

    removes section from each lines of files

    Syntax: cut [opt] [file]example: cut -c 5 file.txtIt display 5rd character from each lines of file.

    Tr

    Translate, squeeze, and/or delete characters

    tr [option] [set1][set2]

    fmtReformat 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 andalso 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 containedis overwritten unless the `-a' option is used.

    alias

    useful to make short name of commandssyntax: alias command='shortname for command'example: alias clear='cl'

    history

    Display all commands used by user .

  • 8/2/2019 linux_ex

    2/3

    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 issed's/data is/data are/g'/assignment/data_source.txtsyntax for sed is Seds///g

    3. For word count wc -w /assignment/data_source

    4. For merging of content of two files use :cat file1.txt file2.txt > file3.txtThe uniq command is used for find and omit repeated entries .

    5. Here we can use tr commandtr - : < customers filename

    or

    open that file in Vi editor and :%s/-/;

    6. To search through subdirectories we can add -r or -Roption it will read all filesrecursively .

    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 .

  • 8/2/2019 linux_ex

    3/3

    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 orderwhich 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 sunbeamsdrwxrw-rw- rainbow

    (3) For tulip to do anythingls l sunbeamsdrwxrwxrwx tulip

    (4) For Marigold to only view(read)

    ls l sunbeamsdrwxr--r-- mariglod

    (5) For Raindrops to read and executels -l sunbeamsdrwxr-xr-x raindrops