lab1 commands filters wildcards

Upload: alok-anand

Post on 02-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Lab1 Commands Filters WildCards

    1/2

    ITWS-IILab-1

    ( Linux Commands + Filters + Shell Wild Cards )

    1. Create two files 1a.txt,1b.txt. Enter one line into both the files,Copy thecontents of both the files into 1c.txt,without using 'cp' command.

    2. Create a file 2a.txt with 20 lines in it. The contents of each line should bethe line number. Copy line number to 1! into another file 2b.txt.

    ". #plit the file 2a.txt created abo$e into two hal$es.

    %. &ind ! ecently modified files in your current wor(ing directory,edirecttheir file names,si)e date and time stamp into another file %a.txt

    !. Count the no of lines,words,characters in the file %a.txt using a singlecommand.

    *. #ort the file 2a.txt in the re$erse order.

    . Combine the lines of file 2a.txt into a single line where each number is

    separated by a space and redirect it to a.txt.

    +. &ind ! largest files in the current folder display on the output screen and

    also in a file +a.txt without using redirection operator.

    . Try outputting contents of '2a.txt' and 'doesntExist.txt'. edirect output to

    'out.txt' and error to 'error.txt'

    10. Count the no of 'Text' files -with .txt extension in the current directory.

    11. &ind all txt files which are accessed 10 minutes ago in your home

    directory.

    12. /ist all the files which has a numeric $alue in its file name followed by anextension.

    1". Try to execute a command ls l lo$e scripting3 the error should not bedisplayed on the terminal and also not redirected to the file.

    1%. n your current folder, create the fi$e folder with the name, hello3, bye3,

    tata3, hello13, bye%times3 and four files with the name boring.txt3, in.c3,

    new3, old3a /ist all the files and folders that ha$e some extension and their name is of at least "

    characters.b /ist all the folder that don't ha$e the numeric letter in their name.

    1!.Create a folder 4ics3.aCreate pics with 5 pic1.6pg, pic2.6pg, ..... pic1.6pg, pic20.6pg

    b /ist all the pics in range ! to 1! - ie pic!.6pg to pic1!.6pg

  • 8/10/2019 Lab1 Commands Filters WildCards

    2/2

    1*.n a folder 7y8ocuments3 you ha$e different documents of different formats.&or eg 5 a.txt , b.doc, c.pdf, d.ppt, e.cpp and so on.

    a9rite a single command to list documents with formats : ;.txt < .pdf=

    b9rite a single command to list documents that do not ha$e format : ;.txt < .pdf=

    1.> folder 4rogramming3 consist of following files 5 a1.c, a2.c, a".c, a%.c, a!.c, b1.txt, b2.txta9rite a single command that deletes all of the files except ;a!.c=

    bCreate a tar archi$e of the folder 4rogramming3 with name 5 ;4rogramming.tar.g)=

    c?i$e a single command to list the contents of the ;4rogramming.tar.g)= 9T@ABT extracting itscontents.

    d?i$e a single command to extract all the -.txt files from ;4rogramming.tar.g)=. The -.c filesshould not be extracted.

    1+. Create files with following file permissions:D 7ynfo.txt Bser can read and write, Ather can only read.

    D unt.txt Bser can execute, ?roup can only read. Athers can neither

    read, write or execute.D ead7e.txt 5 Bser can only read. ?roup can only read. Athers can

    neither read, write or execute.D 9hatsTheBse.txt 5 obody can read, write or execute

    1.Create a group '@'. Create a user 'user1' in that group.

    D Create file nfo.txt

    D Change the permissions of this file so that Anly owner can only read.Athers cannot read, write or execute.

    Change the owner of this file to user1.D ow try to read this file.

    20.ssh into your T web account. -@int: your T web account is;username=Fweb.iiit.ac.in

    D Create a file ".txt. Enter your roll no into it. -@int: Bse cat or $iD Exit from your ssh session.

    D #ecure copy the file ".txt to your local machine.

    D >ppend your ame to the file. Then secure copy it bac( to your Tweb account.