From f7cc095dede5ea72e641ca6d412f300ecba25b72 Mon Sep 17 00:00:00 2001 From: gayumee <149037327+gayumee@users.noreply.github.com> Date: Wed, 28 Feb 2024 20:07:26 +0530 Subject: [PATCH] Update README.md --- README.md | 380 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 316 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 7feb9218..1879aa06 100644 --- a/README.md +++ b/README.md @@ -42,23 +42,50 @@ s.n. dasgupta ### Display the content of the files cat < file1 ## OUTPUT +chanchal singhvi +c.k. shukla +s.n. dasgupta +sumit chakrobarty cat < file2 ## OUTPUT +anil aggarwal +barun sengupta +c.k. shukla +lalit chowdury +s.n. dasgupta # Comparing Files cmp file1 file2 ## OUTPUT - + file1 file2 differ: char1,line1 comm file1 file2 + ## OUTPUT +anil aggarwal + barun sengupta + c.k. shukla +chanchal singhvi +c.k. shukla + lalit chowdury + s.n. dasgupta diff file1 file2 ## OUTPUT +--- file1 ++++ file2 +@@ -1,4 +1,5 @@ +-chanchal singhvi ++anil aggarwal ++barun sengupta + c.k. shukla ++lalit chowdury + s.n. dasgupta +-sumit chakrobarty #Filters @@ -83,16 +110,22 @@ cat > file22 cut -c1-3 file11 ## OUTPUT - +Hel +Thi cut -d "|" -f 1 file22 ## OUTPUT - +1001 +1002 +1003 cut -d "|" -f 2 file22 ## OUTPUT +Ram +tom +Joe cat < newfile @@ -107,13 +140,12 @@ hello world grep Hello newfile ## OUTPUT - - +Hello world grep hello newfile ## OUTPUT - +hello world grep -v hello newfile @@ -124,23 +156,27 @@ grep -v hello newfile cat newfile | grep -i "hello" ## OUTPUT - +Hello world cat newfile | grep -i -c "hello" ## OUTPUT - - +Hello world +hello world +cat newfile | grep -i -c "hello" +## OUTPUT +2 grep -R ubuntu /etc ## OUTPUT - +recursion grep -w -n world newfile ## OUTPUT - +1:Hello world +2:hello world cat < newfile ``` @@ -164,58 +200,64 @@ Linux is best in this World egrep -w 'Hello|hello' newfile ## OUTPUT - +Hello world +hello world egrep -w '(H|h)ello' newfile ## OUTPUT - +Hello world +hello world egrep -w '(H|h)ell[a-z]' newfile ## OUTPUT - - - +Hello world +hello world egrep '(^hello)' newfile ## OUTPUT - - +hello world egrep '(world$)' newfile ## OUTPUT - - +Hello world +hello world egrep '(World$)' newfile ## OUTPUT - +Linux is best in the World egrep '((W|w)orld$)' newfile ## OUTPUT - +Hello world +hello world +Linux is best in this Worl egrep '[1-9]' newfile ## OUTPUT - - +Linux is world number 1 egrep 'Linux.*world' newfile ## OUTPUT - +Linux is world number 1 egrep 'Linux.*World' newfile ## OUTPUT +Linux is best in this World egrep l{2} newfile ## OUTPUT +Hello world +hello world egrep 's{1,2}' newfile ## OUTPUT +Hello world +hello world cat > file23 @@ -234,80 +276,137 @@ cat > file23 sed -n -e '3p' file23 ## OUTPUT - - +1002 | tom | 5000 | Admin sed -n -e '$p' file23 ## OUTPUT - - +1001 | Ram | 10000 | HR sed -e 's/Ram/Sita/' file23 ## OUTPUT - +1001 | Sita | 10000 | HR +1001 | Sita | 10000 | HR +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer +1005 | Sam | 5000 | HR +1004 | Sit | 7000 | Dev +1003 | Joe | 7000 | Developer +1001 | Sita | 10000 | HR sed -e '2s/Ram/Sita/' file23 ## OUTPUT +1001 | Ram | 10000 | HR +1001 | Sita | 10000 | HR +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer +1005 | Sam | 5000 | HR +1004 | Sit | 7000 | Dev +1003 | Joe | 7000 | Developer +1001 | Ram | 10000 | HR sed '/tom/s/5000/6000/' file23 ## OUTPUT - +1001 | Ram | 10000 | HR +1001 | Ram | 10000 | HR +1002 | tom | 6000 | Admin +1003 | Joe | 7000 | Developer +1005 | Sam | 5000 | HR +1004 | Sit | 7000 | Dev +1003 | Joe | 7000 | Developer +1001 | Ram | 10000 | HR sed -n -e '1,5p' file23 ## OUTPUT - +1001 | Ram | 10000 | HR +1001 | Ram | 10000 | HR +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer +1005 | Sam | 5000 | H sed -n -e '2,/Joe/p' file23 ## OUTPUT +1001 | Ram | 10000 | HR +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer sed -n -e '/tom/,/Joe/p' file23 ## OUTPUT +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer seq 10 ## OUTPUT +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 seq 10 | sed -n '4,6p' ## OUTPUT - +4 +5 +6 seq 10 | sed -n '2,~4p' ## OUTPUT - +2 +3 +4 seq 3 | sed '2a hello' ## OUTPUT +1 +2 +hello +3 seq 2 | sed '2i hello' ## OUTPUT - +1 +hello +2 seq 10 | sed '2,9c hello' ## OUTPUT +1 +hello +10 sed -n '2,4{s/^/$/;p}' file23 ## OUTPUT - +$1001 | Ram | 10000 | HR +$1002 | tom | 5000 | Admin +$1003 | Joe | 7000 | Developer sed -n '2,4{s/$/*/;p}' file23 - +## OUTPUT +1001 | Ram | 10000 | HR* +1002 | tom | 5000 | Admin* +1003 | Joe | 7000 | Developer* #Sorting File content cat > file21 @@ -320,7 +419,11 @@ cat > file21 ``` sort file21 ## OUTPUT - +1001 | Ram | 10000 | HR +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer +1004 | Sit | 7000 | Dev +1005 | Sam | 5000 | HR cat > file22 ``` @@ -333,14 +436,25 @@ cat > file22 ``` uniq file22 ## OUTPUT - +1001 | Ram | 10000 | HR +1002 | tom | 5000 | Admin +1003 | Joe | 7000 | Developer +1005 | Sam | 5000 | HR +1004 | Sit | 7000 | Dev #Using tr command cat file23 | tr [:lower:] [:upper:] ## OUTPUT - +1001 | RAM | 10000 | HR +1001 | RAM | 10000 | HR +1002 | TOM | 5000 | ADMIN +1003 | JOE | 7000 | DEVELOPER +1005 | SAM | 5000 | HR +1004 | SIT | 7000 | DEV +1003 | JOE | 7000 | DEVELOPER +1001 | RAM | 10000 | HR cat < urllist.txt ``` www. yahoo. com @@ -356,17 +470,33 @@ www. mrcet.... com ``` cat urllist.txt | tr -d ' ' ## OUTPUT - +www.yahoo.com +www.google.com +www.mrcet....com cat urllist.txt | tr -d ' ' | tr -s '.' ## OUTPUT - +www.yahoo.com +www.google.com +www.mrcet.com #Backup commands tar -cvf backup.tar * ## OUTPUT +bench.py +file1 +file11 +file2 +file21 +file22 +file23 +hello.c +hello.js +newfile +readme.txt +urllist.txt mkdir backupdir @@ -375,19 +505,26 @@ mv backup.tar backupdir tar -tvf backup.tar ## OUTPUT - +-rw-r--r-- user/group 0 2024-02-25 14:30:00 file1.txt +drwxr-xr-x user/group 0 2024-02-25 14:30:00 directory1/ +-rw-r--r-- user/group 1024 2024-02-25 14:30:00 directory1/file2.txt +-rw-r--r-- user/group 2048 2024-02-25 14:30:00 directory1/file3.txt tar -xvf backup.tar ## OUTPUT - +x file1.txt +x directory1/ +x directory1/file2.txt +x directory1/file3.txt gzip backup.tar ls .gz ## OUTPUT +backup.tar.gz gunzip backup.tar.gz ## OUTPUT - +backup.tar # Shell Script ``` @@ -397,6 +534,16 @@ echo 'echo Hello World‘; exit 0 >> my-script.sh chmod 755 my-script.sh ./my-script.sh ## OUTPUT +echo Hello World +cat << stop > herecheck.txt +``` +hello in this world +i cant stop +for this non stop movement +stop +``` +cat herecheck.txt + cat << stop > herecheck.txt @@ -409,7 +556,9 @@ stop cat herecheck.txt ## OUTPUT - +hello in this world +i cant stop +for this non stop movement cat < scriptest.sh ```bash @@ -447,13 +596,23 @@ chmod 777 scriptest.sh ./scriptest.sh 1 2 3 ## OUTPUT +File name is ./scriptest.sh +File name is scriptest.sh +First arg. is 1 +Second arg. is 2 +Third arg. is 3 +Fourth arg. is +The $@ is 1 2 3 +The $\# is $# +The $$ is 124 ls file1 ## OUTPUT - +file1 echo $? ## OUTPUT +0 ./one bash: ./one: Permission denied @@ -464,7 +623,7 @@ abcd echo $? ## OUTPUT - +1 # mis-using string comparisons @@ -496,14 +655,21 @@ echo "$val1 is less than $val2" fi ``` ##OUTPUT - +val1=baseball +val2=hockey +if [ $val1 \> $val2 ] +then +echo "$val1 is greater than $val2" +else +echo "$val1 is less than $val2" +fi chmod 755 strcomp.sh ./strcomp.sh ## OUTPUT - +baseball is less than hockey # check file ownership cat < psswdperm.sh @@ -530,7 +696,7 @@ fi ``` ./psswdperm.sh ## OUTPUT - +You are the owner of the /etc/passwd file # check if with file location cat>ifnested.sh ```bash @@ -576,6 +742,8 @@ fi ./ifnested.sh ## OUTPUT +/root The object exists, is it a file? +No,/root it is not a file! @@ -697,7 +865,13 @@ $ chmod 755 elifcheck.sh $ ./elifcheck.sh ## OUTPUT - +Welcome Ram +Please enjoy your visit +Welcome Rahim +Please enjoy your visit +Special testing account +gganesh, Do not forget to logout when you're done +Sorry, you are not allowed here # testing compound comparisons cat> ifcompound.sh @@ -713,7 +887,7 @@ fi $ chmod 755 ifcompound.sh $ ./ifcompound.sh ## OUTPUT - +The file exists and you can write to it # using the case command cat >casecheck.sh ```bash @@ -732,7 +906,12 @@ esac $ chmod 755 casecheck.sh $ ./casecheck.sh - + ## OUTPUT +Welcome Ram/Rahim +Please enjoy your visit +Special testing account +gganesh, Do not forget to logout when you're done +Sorry, you are not allowed here cat > whiletest ```bash #!/bin/bash @@ -747,7 +926,17 @@ done $ chmod 755 whiletest.sh $ ./whiletest.sh - + ## OUTPUT + 10 +9 +8 +7 +6 +5 +4 +3 +2 +1 cat untiltest.sh ```bash @@ -760,7 +949,11 @@ var1=$[ $var1 - 25 ] done ``` $ chmod 755 untiltest.sh - +## OUTPUT + 100 + 75 + 50 + 25 cat forin1.sh @@ -774,6 +967,13 @@ done ``` $ chmod 755 forin1.sh +## OUTPUT +The next state is Alabama +The next state is Alaska +The next state is Arizona +The next state is Arkansas +The next state is California +The next state is Colorado cat forin2.sh @@ -800,6 +1000,10 @@ done $ chmod 755 forin2.sh $ ./forin2.sh +## OUTPUT +word:I +word:dont know if thisll +word:work cat forin3.sh ```bash @@ -811,6 +1015,13 @@ echo "word:$test" done ``` $ ./forin3.sh +## OUTPUT +word:I +word:don't +word:know +word:if +word:this'll +word:work cat forin1.sh ```bash @@ -845,7 +1056,13 @@ Bhadrachalam Khammam ## OUTPUT - +Visit beautiful Hyderabad +Visit beautiful Alampur +Visit beautiful Basara +Visit beautiful Warangal +Visit beautiful Adilabad +Visit beautiful Bhadrachalam +Visit beautiful Khammam cat forctype.sh ```bash @@ -872,6 +1089,11 @@ done $ chmod 755 forctype.sh $ ./forctype1.sh ## OUTPUT +1 - 5 +2 - 4 +3 - 3 +4 - 2 +5 - 1 cat fornested1.sh ```bash @@ -890,7 +1112,11 @@ $ chmod 755 fornested1.sh $ ./fornested1.sh ## OUTPUT - +1 - 5 +2 - 4 +3 - 3 +4 - 2 +5 - 1 cat forbreak.sh ```bash @@ -929,10 +1155,18 @@ echo "The for loop is completed“ $ chmod 755 forcontinue.sh +$ ./forbreak.sh +## OUTPUT +Iteration number: 1 +Iteration number: 2 $ ./forcontinue.sh ## OUTPUT - +Iteration number: 1 +Iteration number: 2 +Iteration number: 4 +Iteration number: 5 +The for loop is completed cat exread.sh ```bash #!/bin/bash @@ -946,6 +1180,8 @@ $ chmod 755 exread.sh $ ./exread.sh ## OUTPUT +Enter your name: John +Hello John, welcome to my program. cat exread1.sh @@ -958,7 +1194,8 @@ echo "Hello $name, welcome to my program. “ $ chmod 755 exread1.sh ## OUTPUT - +Enter your name: sanju +Hello sanju, welcome to my program. $ ./exread1.sh @@ -997,7 +1234,9 @@ $ chmod 777 argshift.sh ## OUTPUT $ ./argshift.sh 1 2 3 - +1 +2 +3 cat argshift1.sh ```bash #/bin/bash @@ -1014,6 +1253,9 @@ done $ chmod 777 argshift.sh ## OUTPUT $ ./argshift.sh 1 2 3 +1 +2 +3 cat argshift.sh ```bash @@ -1027,7 +1269,9 @@ set +x ``` ## OUTPUT ./argshift.sh 1 2 3 - + 1 +2 +3 cat > nc.awk ```bash @@ -1058,7 +1302,10 @@ ubcdfghj ``` awk -f nc.awk data.dat ## OUTPUT - +total characters 75 +Number of Lines are 10 +No of Words count: 10 + cat > palindrome.sh ```bash #num=545 @@ -1085,7 +1332,12 @@ else fi ``` ## OUTPUT - +Enter the number +121 +Number is palindrome +Enter the number +69 +Number is NOT palindrome # RESULT: The Commands are executed successfully.