Shell Commands-B.keerthi Samhitha
Shell Commands-B.keerthi Samhitha
Pattern
A Pattern is an expression that describes a set of strings which is used to give a concise
description
of a set, without having to list all elements.
eg. ab*cd matches anything that starts with ab and ends with cd etc.
ls *.txt – prints all text files
Text Processing
• cat – concatenate files and print on the standard output
Usage: cat [OPTION] [FILE]...
eg. cat file1.txt file2.txt
cat n file1.txt
• echo – display a line of text
Usage: echo [OPTION] [string] ...
eg. echo I love India
echo $HOME
• wc print
the number of newlines, words, and bytes in files
Usage: wc [OPTION]... [FILE]...
eg. wc file1.txt
wc L file1.txt
sort – sort lines of text files
Usage: sort [OPTION]... [FILE]...
eg. sort file1.txt
sort r file1.txt
System Administration
• chmod – change file access permissions
Usage: chmod [OPTION] [MODE] [FILE]
SHELL COMMANDS
Archival
tar – to archive a file
Usage: tar [OPTION] DEST SOURCE
eg. tar cvf
/home/archive.tar /home/original tar xvf/home/archive.tar
• zip – package and compress (archive) files
Usage: zip [OPTION] DEST SOURSE
eg. zip original.zip original
• unzip – list, test and extract compressed files in a ZIP archive
Usage: unzip filename
eg. unzip original.zip
du – estimate file space usage
SHELL COMMANDS
Advanced Commands
• reboot – reboot the system
Usage: reboot [OPTION]
eg. reboot
• poweroff – power off the system
Usage: poweroff [OPTION]
eg. Poweroff
SHELL COMMANDS
SHELL PROGRAMS
SEARCHING A SUBSTRING IN GIVEN TEXT
PROGRAM:
OUTPUT:
PROGRAM:
OUTPUT:
PROGRAM
for i in *
do
echo Before Converting to uppercase the filename is
echo $i
j=`echo $i | tr '[a-z]' '[A-Z]'`
echo After Converting to uppercase the filename is
echo $j
mv $i $j
done
OUTPUT
PROGRAM
OUTPUT
Pattern
$
$ $
$ $ $
PROGRAM
OUTPUT
cse.sh
SHELL COMMANDS
PROGRAM
OUTPUT
SYSTEM INFORMATION
Hello, 3CSE-A
Current date is = Mar 17 08:38:58 IST 2014
Kernal Name = Linux
User is Who I am
Current Directory = 11scs122
Network name and Node name = linuxmint
Kernal Versio n= #1-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010
Kernal OS = GNU/Linux
kernal release =2.6.32-21-generic
Kernal Processor Type = 2.6.33.85.fcl3.i686.PAE
Kernal All Information = Linux main lab 2.6.33.85.fcl.3 i686.PAE
= #1-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010
I686 i686 i686 GNU/Linux