Você está na página 1de 2

ITWS-II

Lab-1
( Linux Commands + Filters + Shell Wild Cards )
1. Create two files 1a.txt,1b.txt. Enter one line into both the files,Copy the
contents 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 be
the line number. Copy line number 7 to 15 into another file 2b.txt.
3. Split the file 2a.txt created above into two halves.
4. Find 5 Recently modified files in your current working directory,Redirect
their file names,size date and time stamp into another file 4a.txt
5. Count the no of lines,words,characters in the file 4a.txt using a single
command.
6. Sort the file 2a.txt in the reverse order.
7. Combine the lines of file 2a.txt into a single line where each number is
separated by a space and redirect it to 7a.txt.
8. Find 5 largest files in the current folder display on the output screen and
also in a file 8a.txt without using redirection operator.
9. Try outputting contents of '2a.txt' and 'doesntExist.txt'. Redirect output to
'out.txt' and error to 'error.txt'
10. Count the no of 'Text' files (with .txt extension) in the current directory.
11. Find all txt files which are accessed 10 minutes ago in your home
directory.
12. List all the files which has a numeric value in its file name followed by an
extension.
13. Try to execute a command ls -l I love scripting the error should not be
displayed on the terminal and also not redirected to the file.
14. In your current folder, create the five folder with the name, hello, bye,
tata, hello1, bye4times and four files with the name boring.txt, in.c,
new, old
a) List all the files and folders that have some extension and their name is of at least 3
characters.
b) List all the folder that don't have the numeric letter in their name.
15.Create a folder Pics.
a)Create pics with pic1.jpg, pic2.jpg, ..... pic19.jpg, pic20.jpg
b) List all the pics in range 5 to 15 ( ie pic5.jpg to pic15.jpg )

16.In a folder MyDocuments you have different documents of different formats.


For eg a.txt , b.doc, c.pdf, d.ppt, e.cpp and so on.
a)Write a single command to list documents with formats : <.txt & .pdf>
b)Write a single command to list documents that do not have format : <.txt & .pdf>
17.A folder Programming consist of following files a1.c, a2.c, a3.c, a4.c, a5.c, b1.txt, b2.txt
a)Write a single command that deletes all of the files except <a5.c>
b)Create a tar archive of the folder Programming with name <Programming.tar.gz>
c)Give a single command to list the contents of the <Programming.tar.gz> WITHOUT extracting its
contents.
d)Give a single command to extract all the (*.txt) files from <Programming.tar.gz>. The (*.c) files
should not be extracted.
18. Create files with following file permissions:
MyInfo.txt - User can read and write, Other can only read.
RunIt.txt - User can execute, Group can only read. Others can neither
read, write or execute.
ReadMe.txt User can only read. Group can only read. Others can
neither read, write or execute.
WhatsTheUse.txt Nobody can read, write or execute
19.Create a group 'IIIH'. Create a user 'user1' in that group.
Create file Info.txt
Change the permissions of this file so that Only owner can only read.
Others cannot read, write or execute.
Change the owner of this file to user1.
Now try to read this file.
20.ssh into your IIIT web account. (Hint: your IIIT web account is
<username>@web.iiit.ac.in)
Create a file 3.txt. Enter your roll no into it. (Hint: Use cat or vi)
Exit from your ssh session.
Secure copy the file 3.txt to your local machine.
Append your Name to the file. Then secure copy it back to your IIIT
web account.

Você também pode gostar