Professional Documents
Culture Documents
#!/bin/bash -x
for file in 'ls*.txt';
do
folder='echo $file | awk -F. '{print $1}''
if[-d $folder]
then
rm -r $folder;
fi
#echo creating folder ($folder);
mkdir $folder;
cp $file $folder;
done
$ chmod +x folder
$ nano folder
$ ls
OUTPUT :
OUTPUT:
the folder doesnot exists
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--
3.append current dates to all log files name which has extension .log.1 from a
folder
OUTPUT:
abc.20201017.log.1
def.20201017.log.1
ghi.20201017.log.1
jkl.20201017.log.1
mno.20201017.log.1
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
10.56.19.3
10.56.0.3
10.56.21.2
10.56.1.3
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--
$ ls
access.log debug.log linux_problem_sheet.pdf
data.csv linux_chit_sheet.pdf README.md
7.find a word "systemd" from all log files in the folder /var/log
$ cd /var/log
$ ls
$ls *.log | grep systemd
0
--------------------------------------------alternate
way--------------------------------------------------------------------------------
----------------------------
vamshi krishna@DESKTOP-VPAS95C MINGW64 ~/terminalcommands/linux-content (master)
$ grep -o -i system access.log | wc -l //using
access.log//
6
8.find the differences between original file and the updated file
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------
PRINT JOB TITLE AND OVERTIME PAY BETWEEN 7000 AND 10000
print employee name and total pay whose base pay >10000
11. PRINT LIST OF WEB RESPONSE CODE COUNT IN THE UNIQUE SORTED ORDER AT SPECIFIC
HOURS
12. PRINT LIST OF LAST 4 FREQUENTLY ACCESS UNIQUE URLS AT PARTICULAR HOURS
$ cat access.log |awk '{print $20}' | cut -d" " -f 9,10 |sort| uniq -c | tail
-4
455 Chrome/77.0.3865.90
177 like
33 Firefox/69.0"
7 Ubuntu/10.04
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------
13. archive the files that were modified 7 days ago and move them to the backup
folder
-----------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------------------------------
14. CREATE A PROCESS LIST TABLE DISPLAYS PID PPID AND STIME
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------
15. get user info from etcpassword.txt and change the user
Service:/var/db/appstore:/usr/bin/false
Server:/Library/WebServer:/usr/bin/false
Helper:/var/db/lockdown:/usr/bin/false
Ticket:/var/empty:/usr/bin/false
Service:/var/empty:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Anonymous:/var/empty:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Daemon:/var/db/ondemand:/usr/bin/false
Service:/var/empty:/usr/bin/false
Daemon:/var/db/findmydevice:/usr/bin/false
User:/var/db/cmiodalassistants:/usr/bin/false
Daemon:/var/db/nearbyd:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Server:/var/spool/postfix:/usr/bin/false
Service:/var/empty:/usr/bin/false
Service:/var/empty:/usr/bin/false
Daemon:/var/db/geod:/usr/bin/false
Desktop:/var/empty:/usr/bin/false
User:/var/empty:/usr/bin/false
separation:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Service:/var/db/softwareupdate:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Agent:/var/empty:/usr/bin/false
Agent:/var/empty:/usr/bin/false
Service:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Kerberos:/var/empty:/usr/bin/false
Service:/var/empty:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Account:/var/empty:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
User:/var/db/hidd:/usr/bin/false
Daemon:/var/db/timed:/usr/bin/false
User:/var/empty:/usr/bin/false
Administrator:/var/root:/bin/sh
Services:/var/root:/usr/bin/false
Services:/var/networkd:/usr/bin/false
Assistant:/var/empty:/usr/bin/false
Services:/var/spool/cups:/usr/bin/false
AppLaunch:/var/empty:/usr/bin/false
Daemon:/var/empty:/usr/bin/false
Documentation:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Server:/var/empty:/usr/bin/false
Administrator:/var/imap:/usr/bin/false
Server:/var/empty:/usr/bin/false
Daemon:/var/virusmails:/usr/bin/false
Daemon:/var/virusmails:/usr/bin/false
Owner:/var/empty:/usr/bin/false
./evenoddseries
+ NUMS='1 2 3 4 5 6 7 8 9 10'
+ for NUM in $NUMS
++ expr 1 % 2
+ q=1
+ '[' 1 -eq 0 ']'
+ echo 'odd number'
odd number
#! /bin/bash -x
b=`expr 9 \* 3 + 8 - 5`
z=$(( b ))
echo $z