Linux Assignment
Linux Assignment
Date: 26-02-2011
1. Write a small shell script that adds an extension “.new” to all the files in a directory?
#! /bin/bash
For file in `ls`
do
mv $file $file.new
done
2. What is the difference between listing the content of directory play with ls –l and ls –L?
ls –l command is used to display the properties of all files and folders in current
directory. Properties may be file permissions, id, time, size ect.
ls –L command is used to display the information about the symbolic link references
for the files.
c. View a file
cat <file/folder>
e. Show how much disk space a directory and all its files contain
du <file/folder>
f. Delete a link
rm <linkname>
unlink <linkname>
7. List all the files in the current directory having “I” as the second letter in their names?
ls ?[i]*
8. List all the files in the current directory having “a” in their names?
ls *a*
9. Remove all the directories which ends with “run” in the present directory?
For empty directories: rmdir *run
For non empty directories: rm -fr *run