Vous êtes sur la page 1sur 11

user14@Linux1234:~/dir> cat >cfile1

c
d
e
f
user14@Linux1234:~/dir> comm cfile cfile1
a
b
c
d
e
f
user14@Linux1234:~/dir> comm cfile cfile1 -1
c
d
e
f
--------------------------------------------------------------------------------------------user14@Linux1234:~/dir> tr "[a-z]" "[A-Z]" <18jan12
BELGIAN WAFFLES
STRAWBERRY BELGIAN WAFFLES
BERRY-BERRY BELGIAN WAFFLES
FRENCH TOAST
HOMESTYLE BREAKFAST
--------------------------------------------------------------------------------------------------chmod 777 18jan12
user14@Linux1234:~/dir> ls -l
total 360
-rwxrwxrwx 1 user14 USERS
104 2012-01-18 09:12 18jan12
user14@Linux1234:~/dir>
1001 unix 375
1002 learning unix 250
1003 shell 450
1004 device 375
user14@Linux1234:~/dir>
1001
1002
1003
1004
user14@Linux1234:~/dir>
1001 unix 375
1002 learning unix 250
1003 shell 450
1004 device 375
user14@Linux1234:~/dir>
unix 375
learning unix
shell 450
device 375
user14@Linux1234:~/dir>
unix 375
learning unix 250

cat >cutcommand

cut -c1-4 cutcommand

cut -d"|" -f2,3 cutcommand

cut -d" " -f2,3 cutcommand

cut -d" " -f2-13,3 cutcommand

shell 450
device 375
user14@Linux1234:~/dir> cut -d" " -f2-8,3 cutcommand
unix 375
learning unix 250
shell 450
device 375
user14@Linux1234:~/dir> cut -d" " -f2-7,3 cutcommand
unix 375
learning unix 250
shell 450
device 375
user14@Linux1234:~/dir> cut -d" " -f2-1,3 cutcommand
cut: invalid byte, character or field list
Try `cut --help' for more information.
user14@Linux1234:~/dir> cut -d" " -f2-4,3 cutcommand
unix 375
learning unix 250
shell 450
device 375
user14@Linux1234:~/dir> cut -d" " -f2,3 cutcommand
unix 375
learning unix
shell 450
device 375
user14@Linux1234:~/dir> cut -d" " -f2-,3 cutcommand
unix 375
learning unix 250
shell 450
device 375
-------------------------------------------------------------------------------user14@Linux1234:~/dir> cat >paste
1010
2323
1212
3434
user14@Linux1234:~/dir> cat name
cat: name: No such file or directory
user14@Linux1234:~/dir> cat >name
qwqw
we
rer
yuy
user14@Linux1234:~/dir> paste -d"|" paste name
1010|qwqw
2323|we
1212|rer
3434|yuy
--------------------------------------------------------------------------------------user14@Linux1234:~/dir> sort -t "|" -k2,1 -k1,1 lk
1010|qwqw
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir> sort -t "|" -k2,3 -k1,1 lk
1010|qwqw

user14@Linux1234:~/dir>
0123|AAdi
1299|ajKl
3456|poAd
7809|zzgh
user14@Linux1234:~/dir>
3456|poAd
0123|AAdi
7809|zzgh
1299|ajKl
user14@Linux1234:~/dir>
0123|AAdi
1299|ajKl
3456|poAd
7809|zzgh
user14@Linux1234:~/dir>
0123|AAdi
1299|ajKl
3456|poAd
7809|zzgh
user14@Linux1234:~/dir>
7809|zzgh
0123|AAdi
3456|poAd
1299|ajKl
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir>
1010|qwqw
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir>
1010|qwqw
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir>
1010|qwqw
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir>
1010|qwqw
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir>
2323|we
1212|rer
3434|yuy
1010|qwqw
user14@Linux1234:~/dir>
1010|qwqw
1212|rer
2323|we
3434|yuy

sort -f -t "|" -k2.2 res1

sort -f -t "|" -k2.3 res1

sort -f -t "|" -k2,2 -k1,1 res1

sort -f -t "|" -k2,2 -k1,3 res1

sort -f -t "|" -k1.3 res1

sort -t "|" -k2,2 -k1,1 lk

sort -t "|" -k2,2 -k1 lk

sort -t "|" -k2 -k1 lk

sort -t "|" -k2,1 -k1,4 lk

sort -t "|" -k2.2,2.3 lk

sort -t "|" -k2.1,2.3 lk

user14@Linux1234:~/dir> sort -t "|" -k2.2 -k1 lk


2323|we
1212|rer
3434|yuy
1010|qwqw
user14@Linux1234:~/dir> sort -t "|" -k2 -k1.3 lk
1010|qwqw
1212|rer
2323|we
3434|yuy
user14@Linux1234:~/dir> sort -t "|" -k2.4 lk
1212|rer
2323|we
3434|yuy
1010|qwqw
user14@Linux1234:~/dir> cat >dup
1
45
1
1
23
67
09
user14@Linux1234:~/dir> sort -n dup|uniq
1
09
23
45
67
user14@Linux1234:~/dir> sort -n dup|uniq -c
3 1
1 09
1 23
1 45
1 67

user14@Linux1234:~/dir> cat >text1


sidd B-1/250 kalyani WB
Tito A-3/11 Thane MH
Ryan D-17 Lake Town WB
Miter C/268 G.B Road BH
user14@Linux1234:~/dir> sed 's/WB/,Wesstbengal/' text1
sidd B-1/250 kalyani ,Wesstbengal
Tito A-3/11 Thane MH
Ryan D-17 Lake Town ,Wesstbengal
Miter C/268 G.B Road BH
user14@Linux1234:~/dir> sed 's/WB/Wesstbengal/' text1
sidd B-1/250 kalyani Wesstbengal
Tito A-3/11 Thane MH
Ryan D-17 Lake Town Wesstbengal
Miter C/268 G.B Road BH
user14@Linux1234:~/dir> sed -e 's/WB/,West bengal/' -e's/BH/,Bihar/' text1
sidd B-1/250 kalyani ,West bengal
Tito A-3/11 Thane MH

Ryan D-17 Lake Town ,West bengal


Miter C/268 G.B Road ,Bihar

user14@Linux1234:~/dir> sed 's/WB/,Wesstbengal/p' text1


sidd B-1/250 kalyani ,Wesstbengal
sidd B-1/250 kalyani ,Wesstbengal
Tito A-3/11 Thane MH
Ryan D-17 Lake Town ,Wesstbengal
Ryan D-17 Lake Town ,Wesstbengal
Miter C/268 G.B Road BH

user14@Linux1234:~/dir> sed -n 's/WB/Wesstbengal/p' text1


sidd B-1/250 kalyani Wesstbengal
Ryan D-17 Lake Town Wesstbengal
---------------------------------------------------------------------206,William,MAYA,WGIETZ,515.123.8181,07-JUN-94,AC_ACCOUNT,8300,,205,110
user14@Linux1234:~/dir> awk -F
e.txt
%2d,%-20s 121 William
user14@Linux1234:~/dir> awk -F
e.txt
%2d,%-20s 121 MAYA
user14@Linux1234:~/dir> awk -F
121 WGIETZ
user14@Linux1234:~/dir> awk -F
txt
121 206 William 07-JUN-94 205

"," '$1=="206" {print "%2d,%-20s",NR,$2}' employe


"," '$1=="206" {print "%2d,%-20s",NR,$3}' employe
"," '$1=="206" {print NR,$4}' employee.txt
"," '$1=="206" {print NR,$1,$2,$6,$10}' employee.

user14@Linux1234:~/dir> awk -F "," '$3=="William" {print NR,$1,$2,$6,$10}' emplo


yee.txt
user14@Linux1234:~/dir> awk -F "," '$2=="William" {print NR,$1,$2,$6,$10}' emplo
yee.txt
86 171 William 23-FEB-99 148
121 206 William 07-JUN-94 205
user14@Linux1234:~/dir> awk -F "," '$2=="William" {print NR,$2}' employee.txt
86 William
121 William
user14@Linux1234:~/dir> awk -F "," '$2=="William" {print $2}' employee.txt
William
William
-----------------------------------------------------------------------------------------------echo "1.filecheck"
echo "2.file existance"
echo "enter the choice(1,2)"
read choice
case $choice in
1) echo "enter the filename"

read filename
if [ -z $filename ]
then
echo "plz enter the filename"
fi;;
2) echo "enter the filename"
read filename
if [ ! -f $filename ]
then
echo "file doesnt exist"
else
echo "file exists"
fi;;
*) echo wrong choice;;
esac
--------------------------------------------------------------------------------------------echo enter the file/dir name
read fn
if [ ! -e $fn ]
then
echo "file/dir doesn't exist"
else
echo "file/dir exists"
fi
#! check for directory ,if not existing then create
makedir()
{
mkdir $fn
cd $fn
}
echo enter the dir name
read fn
if [ ! -d $fn ]
then
makedir $fn
else
echo "dir exists"
fi
--------------------------------------------{
echo enter targetpath
read target
cp $source $target
echo copied successfully
}
add()
{
touch $source
echo file created
}
makedir()
{
mkdir $source
}
copy1()
{
cp -r $source $target

}
move()
{
echo enter target name
read target
mv $source $target
}
echo enter the file name
read source
if [ ! -f $source ]
then
add $source
copy $source
else
echo file exists
move $source
fi
-------------------------------------------------------------------------------------create()
{
touch $sfile
echo "file $sfile successfully created"
}
createdir()
{
mkdir $sfile
cd $sfile
echo "directory $sfile successfully created"
}
copy()
{
echo enter the destination file
read dfile
cp $sfile $dfile
echo " file $sfile copied to $dfile successfuly "
}
move()
{
echo "enter the target file"
read tfile
mv $sfile $tfile
echo " file $sfile moved to $tfile successfully"
}
echo "1.create file"
echo "2.create dir"
echo "3.copy files"
echo "4.move files"
echo "enter choice(1,2,3,4)"
read choice
case $choice in
1)echo enter the filename
read sfile
if [ -z $sfile ]
then
echo "invalid file"
elif [ ! -f $sfile ]
then
create $sfile
else

echo "file exists"


fi;;
2)echo enter the directory name
read sfile
if [ -z $sfile ]
then
echo "invalid directory file"
elif [ ! -d $sfile ]
then
echo "directory doesn't exists"
createdir $sfile
else
echo "directory exists"
fi;;
3)echo enter the source file
read sfile
if [ -z $sfile ]
then
echo "invalid file"
elif [ ! -f $sfile ]
then
echo " file doesn't exists"
else
echo "file exists"
copy $sfile
fi;;
4)
echo enter the source file
read sfile
if [ -z $sfile ]
then
echo "invalid file"
elif [ ! -f $sfile ]
then
echo " file doesn't exists"
else
echo "file exists"
move $sfile
fi;;
*)echo "invalid option"
esac
--------------------------------------------------------------------------------------------func1()
{
echo "enter yes or no"
read sd
if [ $sd == y ]
then
return 0
else
return 1
fi
}

func2()
{
echo enter the file to delete
read file
if func1
then
rm $file
echo "file removed"
else
echo "file not deleted"
fi
}
func3()
{
echo had your lunch
if func1
then
echo "healthy body"
else
echo "unhealthy"
fi
}
echo "to delete file"
func2
echo "be ready for question"
func3
func4()
{
echo is your lyf goin good
if func1
then
echo cool enjoy lyf
else
echo do soul searching
fi
}
echo "to delete file"
func2
echo "be ready for question"
func3
echo "all abt lyf"
func4
-----------------------------------------------------------------------------------------echo "enter the date in given format YYYY-MM-DD"
read date
date -d "$date" >day
cut -d" " -f1 day >check
echo ` cat check`
case `cat check` in
Sun )

echo " good day ";;


Mon )
echo "love";;
Tue )
echo "lasy";;
Thu )
echo "cool";;
esac
------------------------------------------------------------------------------------------echo "1.addition"
echo "2.subtract"
echo "3.multiply"
echo "4.divide"
echo "enter choice(1,2,3,4)"
read choice
case $choice in
1)echo enter 2 numbers
read n1 n2
add=`expr $n1 + $n2`
echo $add;;
2)echo enter 2 numbers
read n1 n2
sub=`expr $n1 - $n2`
echo $sub;;
4)echo enter 2 numbers
read n1 n2
if [ $n2 -eq 0 ]
then
echo error
else
di=`expr $n1 / $n2`
echo "$di"
fi;;
3)echo enter 2 numbers
read n1 n2
mul=`expr $n1 \* $n2`
echo "$mul";;
*)echo invalid choice
esac
---------------------------------------for var in $1 $2 $3 $4
do
var2=`who|grep -w -c "$var"`
if [ $var2 -gt 0 ]
then
echo "user $var logged in"
else
echo "user logged out"
fi
done
--------------------------------------------------echo enter the userid
read id
var=`who|grep -w -c $id`
if [ $var -gt 0 ]
then
echo $id logged in
else
echo $id logged out

fi
-------------------------------------------------------