Академический Документы
Профессиональный Документы
Культура Документы
Session-1:
b)use vi editor to create a file called myfile.txt which contains some text
c)correct typing errors during creation
CODE:
#!/bin/bash
BAK="/sout/email"
/bin/rm $BAK/*
NOW=$(date +"%d-%m-%Y")
ATTCH="/sout/backup.$NOW.tgz"
MTO="you@yourdomain.com"
for db in $HDBS
do
FILE="$BAK/$db.$NOW-$(date +"%T").gz"
DBS $(date)
EOF
OUTPUT:
Jan 26 20:53:31 dell6400 logger: System rebooted for hard disk upgrade
B) use vi editor to create a file called myfile.txt which contains some text
CODE:
WEEK-2
1) Use the cat command to create a file containing the
following data. Call it my table. Sort the mytable.
Swap fields 2 and 3 of mytable. Call it mytable.
Print the new file mytable.
Ans) a) Creating the file mytable. Use tabs to
separate the fields.
$ cat > mytable
1425 Ravi 15.65
4320 Ram 26.27
6830 Raj 36.15
1450 Sita 21.86
^d
b) Displaying the file mytable contents: $ cat
mytable
c) Sorting the file mytable: $ sort mytable
d) Swaping the fields 2 and 3
$ cut –f1 mytsble >file1
$ cut -f2 mytable >fie2
$ cut -f3 mytable >file3
$ cut -f4 mytable >file4
$ paste file1 file3 file2 file4 >mytable
$ cat mytable
f) Printing the file mytable: $ lpr mytable
endsw