diff --git a/README.md b/README.md index 7feb9218..ea96b57e 100644 --- a/README.md +++ b/README.md @@ -42,24 +42,48 @@ s.n. dasgupta ### Display the content of the files cat < file1 ## OUTPUT - - - +``` +chanchal singhvi +c.k. shukla +s.n. dasgupta +sumit chakrobarty +^d +``` cat < file2 ## OUTPUT - - +cat > file2 +``` +anil aggarwal +barun sengupta +c.k. shukla +lalit chowdury +s.n. dasgupta +^d +``` # Comparing Files cmp file1 file2 -## OUTPUT + -comm file1 file2 ## OUTPUT +![303979828-3d17b2b3-39c8-43a8-abdc-519c900acba8](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/75a5512e-1a3b-45f7-ad9a-369f872d4e8a) + + + +comm file1 file2 - -diff file1 file2 ## OUTPUT +![303980017-9f15abc6-fa53-4ce6-9690-41d0c5527c64](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/06aaf5ba-ea64-4e0c-8499-115f566e830f) + + + +diff file1 file2 + + +##OUTPUT +![303980022-6f0df5d6-6dc0-473f-8764-8f8788dc1423](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/dd5d576c-fdad-4142-8a42-957143d516bb) + + #Filters @@ -83,16 +107,18 @@ cat > file22 cut -c1-3 file11 ## OUTPUT +![303980526-e74cc399-e869-4514-9294-e4d66bdbb553](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/057abf47-bdbc-4ed1-b8c0-df0302401aad) cut -d "|" -f 1 file22 ## OUTPUT - +![303980625-45a81470-3b96-4c0b-9c34-21ef65d280c1](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/64f3b346-85d6-40e6-a5ca-0795b38c67c2) cut -d "|" -f 2 file22 ## OUTPUT +![303980718-81235175-e464-4178-a1da-d78a36605b9b](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/26e24d41-1567-4bb7-a427-463ae5f32f95) cat < newfile @@ -108,10 +134,12 @@ hello world grep Hello newfile ## OUTPUT +![304111559-7d5dc360-1c3a-4ec4-9367-a9d3ebf3da9d](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/a75c35a9-3407-45bb-a60c-51ac39e93dd0) grep hello newfile ## OUTPUT +![304111717-3b622860-62e3-4eba-88ad-9644765927df](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/1fed07d9-9937-4958-934c-dae3f0c403d3) @@ -119,10 +147,12 @@ grep hello newfile grep -v hello newfile ## OUTPUT +![304112410-0a4e551a-c35b-4f53-a343-e0c41baeefdf](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/675e0427-572c-4aca-953c-cc45455944ae) cat newfile | grep -i "hello" ## OUTPUT +![304112674-10be401c-081e-4138-af1f-88aa41158c77](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/8dea6fe3-2ada-4ab9-ae14-db1f7eaa36f7) @@ -130,17 +160,15 @@ cat newfile | grep -i "hello" cat newfile | grep -i -c "hello" ## OUTPUT - +![304113192-a2eb2603-767e-486a-bb38-c9e1f53f51a3](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/fd4ce646-de28-4957-83b6-e305c1f4439a) grep -R ubuntu /etc ## OUTPUT - - - grep -w -n world newfile ## OUTPUT +![304114184-cb370c18-be74-432d-9314-51f331acf7df](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/dfaf1853-3e52-470b-9bc5-38d3057ce4b2) cat < newfile ``` @@ -164,58 +192,70 @@ Linux is best in this World egrep -w 'Hello|hello' newfile ## OUTPUT +![304114445-2d621e3e-9f9a-44ac-a6db-043fdba5cc21](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/63f44836-f6b6-4d66-bdf4-9a53fb6fe0d4) egrep -w '(H|h)ello' newfile ## OUTPUT +![304114664-f2413676-3063-4310-9007-e31987305c59](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/8cc574fc-24a7-4e1d-bfd0-56ca0ff8dd45) egrep -w '(H|h)ell[a-z]' newfile ## OUTPUT +![304116131-7a74a2cf-5316-47fc-8448-8cae00930409](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/50e2bb9b-2c9b-4df4-9d46-903adbd0e6da) egrep '(^hello)' newfile ## OUTPUT +![304751858-2097ab41-753f-4c27-bf30-f3c2b3edd826](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/67ad9538-9b91-423e-8266-1fb2edbc9d40) egrep '(world$)' newfile ## OUTPUT +![304752068-d6105214-5e17-4bcf-82c9-256ac369f797](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/6339ba41-1e5e-443d-825d-b2809e856a19) egrep '(World$)' newfile ## OUTPUT +![304752280-d3019e06-e463-45ab-bf66-985f54a7edb9](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/fb6711f3-9556-4718-a749-555f06debab1) egrep '((W|w)orld$)' newfile ## OUTPUT +![304752550-c0c28d29-8373-4c75-b10a-e3a1ee97271a](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/cc9d61d6-82b4-42a2-a3eb-593038c19fc7) egrep '[1-9]' newfile ## OUTPUT +![304752743-d525b4d0-ceaf-456e-b23e-98fc98180629](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/6d099778-2b88-4e6f-8b06-c40b2f09a638) egrep 'Linux.*world' newfile ## OUTPUT +![304753008-b3b81c41-51b4-406b-b712-21a2a4c9d97c](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/d1c365df-03a4-4e54-928e-4a381e058096) egrep 'Linux.*World' newfile ## OUTPUT +![304753573-6bb38c3a-f787-4522-9190-8a797f9ec430](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/591ab9e6-e543-40a3-a4ec-f9012f8ceadf) egrep l{2} newfile ## OUTPUT +![304754057-82fd9878-0b30-4a54-8ab5-18dd15381f65](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/98619322-54a4-4a4c-ad34-fa84af7dfff4) egrep 's{1,2}' newfile ## OUTPUT +![304754458-c92a0337-816f-4d2f-a34d-6748b3cb1bee](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/91245c5a-f669-4b1c-8641-44667f0689f7) cat > file23 @@ -234,79 +274,97 @@ cat > file23 sed -n -e '3p' file23 ## OUTPUT +![304757591-a648b63d-4908-491b-83e2-15d2a6549860](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/6067006c-52ab-4263-bb7c-8675a5cba9d7) sed -n -e '$p' file23 ## OUTPUT - - - sed -e 's/Ram/Sita/' file23 ## OUTPUT +![304758431-084144ca-9506-4676-8b2a-4ce86686c9e6](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/ea154aa6-2031-4bc9-a5fa-d246da2078ce) sed -e '2s/Ram/Sita/' file23 ## OUTPUT +![304758637-033e8dc7-f710-400f-9fa0-78d15ed14fce](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/b35d81b6-ed9b-4d25-b8cb-d3ca5c25fdf0) sed '/tom/s/5000/6000/' file23 ## OUTPUT +![304759583-b67f110e-2c70-4583-a1be-a37ad91ad49d](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/e6e1ba26-5291-43fd-8f40-d6fe00a20498) sed -n -e '1,5p' file23 + ## OUTPUT +![304759738-4539c59e-1967-4511-aa85-02e0193a1e13](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/d727de65-8c1f-474b-a1a7-2d87bbc4b354) + sed -n -e '2,/Joe/p' file23 ## OUTPUT +![304759889-30234a9f-dd11-4ae5-b7a5-9045148072a0](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/ca6da655-591e-498b-9afb-e9bcd8e09c64) sed -n -e '/tom/,/Joe/p' file23 ## OUTPUT +![304766794-9a68ec8b-c637-4d4f-b099-279531805f0b](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/7a82bd4e-4d0e-4340-89d1-882aa938ae94) + seq 10 ## OUTPUT +![304767015-a6426c76-366f-4acd-9a74-05d4c22cd1ef](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/fa19b57d-1c9d-4bef-81a8-159ef1e802be) seq 10 | sed -n '4,6p' ## OUTPUT +![304767368-be70bf5e-1699-41fc-aa85-bdcde8e946ca](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/a4650fd0-7816-4e90-88fe-036a692d2e76) seq 10 | sed -n '2,~4p' ## OUTPUT +![304767623-4dae8842-394b-4660-98d8-f1ff6de58121](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/e76d46db-4e87-4616-adf3-209f22705a28) seq 3 | sed '2a hello' ## OUTPUT +![304768147-98a1731b-3015-45f1-ba23-6cb031f09c8d](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/b251a39b-a769-44e6-aca2-a4a33e8afc48) seq 2 | sed '2i hello' -## OUTPUT +##OUTPUT + +![304768296-37f79adc-6b21-4499-bbfa-d74aeae1461a](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/50840e06-7531-454b-893b-82157fa696d9) seq 10 | sed '2,9c hello' ## OUTPUT +![304768441-9c4330d4-0447-451d-a81a-cf358636d16d](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/02460176-5dbc-4cd3-86e2-676ef79130bc) + sed -n '2,4{s/^/$/;p}' file23 ## OUTPUT - +![304768689-da40ce9b-3d87-4252-90db-988a1f344a81](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/757e595f-068c-4a2d-9a74-a0c5c280d674) sed -n '2,4{s/$/*/;p}' file23 +##OUTPUT + +![304769027-3459be51-4d3f-4d3b-a8ad-e63a1fcadd62](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/3a948998-5ccc-471c-8301-871e4f040ac5) #Sorting File content @@ -321,6 +379,7 @@ cat > file21 sort file21 ## OUTPUT +![304769719-6ddff4be-6d23-46ab-9e48-2d436930fea3](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/9dcd56c0-8260-4a34-a658-4a9bedfc00a6) cat > file22 ``` @@ -335,11 +394,15 @@ uniq file22 ## OUTPUT +![304771138-0b50c2dc-0ef6-4965-92c6-5b0ff5735bd1](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/10564297-a8ca-42e7-9e7b-11d2f5823b34) + #Using tr command cat file23 | tr [:lower:] [:upper:] ## OUTPUT + +![304771761-734761d9-86e9-4b02-9948-1a8de5e92c36](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/9ddada14-d8d3-4b5a-a383-4e756bac6c9c) cat < urllist.txt ``` @@ -358,16 +421,19 @@ cat urllist.txt | tr -d ' ' ## OUTPUT - + ![304797034-9a10a40c-28d3-4c0d-929f-609b1615fb79](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/a3958730-a84b-4be3-934c-75127fd45e20) + cat urllist.txt | tr -d ' ' | tr -s '.' ## OUTPUT +![304797372-2499ab97-1897-440e-b6b7-2d2f3a95a31a](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/36ba05c2-828f-4cf0-b89c-7704eb2a9ca0) #Backup commands tar -cvf backup.tar * ## OUTPUT +![304797792-7f1581bd-5f95-4e4e-866f-1699b6f40de5](https://github.com/23004513/OS-Linux-commands-Shell-script/assets/138973069/59aebb74-5bab-4b16-856c-0702c0987aa0) mkdir backupdir @@ -375,17 +441,12 @@ mv backup.tar backupdir tar -tvf backup.tar ## OUTPUT - - tar -xvf backup.tar ## OUTPUT - gzip backup.tar - ls .gz ## OUTPUT - -gunzip backup.tar.gz + gunzip backup.tar.gz ## OUTPUT @@ -397,8 +458,6 @@ echo 'echo Hello World‘; exit 0 >> my-script.sh chmod 755 my-script.sh ./my-script.sh ## OUTPUT - - cat << stop > herecheck.txt ``` hello in this world @@ -409,8 +468,6 @@ stop cat herecheck.txt ## OUTPUT - - cat < scriptest.sh ```bash \#!/bin/sh @@ -447,26 +504,17 @@ chmod 777 scriptest.sh ./scriptest.sh 1 2 3 ## OUTPUT - - ls file1 ## OUTPUT - echo $? ## OUTPUT ./one bash: ./one: Permission denied - -echo $? + echo $? ## OUTPUT - -abcd - -echo $? + abcd + echo $? ## OUTPUT - - - # mis-using string comparisons cat < strcomp.sh @@ -496,15 +544,10 @@ echo "$val1 is less than $val2" fi ``` ##OUTPUT - - - chmod 755 strcomp.sh ./strcomp.sh ## OUTPUT - - # check file ownership cat < psswdperm.sh ```bash @@ -530,7 +573,6 @@ fi ``` ./psswdperm.sh ## OUTPUT - # check if with file location cat>ifnested.sh ```bash @@ -576,9 +618,6 @@ fi ./ifnested.sh ## OUTPUT - - - # using numeric test comparisons cat > iftest.sh ```bash @@ -618,9 +657,8 @@ fi $ chmod 755 iftest.sh -$ ./iftest.sh +$ ./iftest.sh ##OUTPUT - # check if a file cat > ifnested.sh ```bash @@ -666,10 +704,8 @@ fi ``` $ chmod 755 ifnested.sh - -$ ./ifnested.sh + $ ./ifnested.sh ##OUTPUT - # looking for a possible value using elif cat elifcheck.sh ```bash @@ -694,11 +730,8 @@ fi ``` $ chmod 755 elifcheck.sh - $ ./elifcheck.sh ## OUTPUT - - # testing compound comparisons cat> ifcompound.sh ```bash @@ -713,7 +746,6 @@ fi $ chmod 755 ifcompound.sh $ ./ifcompound.sh ## OUTPUT - # using the case command cat >casecheck.sh ```bash @@ -730,9 +762,7 @@ echo "Sorry, you are not allowed here";; esac ``` $ chmod 755 casecheck.sh - $ ./casecheck.sh - cat > whiletest ```bash #!/bin/bash @@ -890,8 +920,6 @@ $ chmod 755 fornested1.sh $ ./fornested1.sh ## OUTPUT - - cat forbreak.sh ```bash #!/bin/bash @@ -907,7 +935,6 @@ done echo "The for loop is completed“ ``` ## OUTPUT - $ chmod 755 forbreak.sh $ ./forbreak.sh @@ -946,8 +973,6 @@ $ chmod 755 exread.sh $ ./exread.sh ## OUTPUT - - cat exread1.sh ```bash #!/bin/bash @@ -980,11 +1005,7 @@ fi ``` ## OUTPUT ./funcex.sh - - ./funcex.sh 1 2 - - cat argshift.sh ```bash #!/bin/bash @@ -1027,9 +1048,7 @@ set +x ``` ## OUTPUT ./argshift.sh 1 2 3 - - -cat > nc.awk + cat > nc.awk ```bash BEGIN{} { @@ -1058,8 +1077,7 @@ ubcdfghj ``` awk -f nc.awk data.dat ## OUTPUT - -cat > palindrome.sh + cat > palindrome.sh ```bash #num=545 echo "Enter the number" @@ -1085,7 +1103,5 @@ else fi ``` ## OUTPUT - - # RESULT: The Commands are executed successfully.