From bbb92f66f1e55f9b5e68284e9890539d23e0de04 Mon Sep 17 00:00:00 2001 From: sanjaysivaramakrishnan <151629616+sanjaysivaramakrishnan@users.noreply.github.com> Date: Fri, 9 Aug 2024 11:44:20 +0530 Subject: [PATCH] Update README.md --- README.md | 310 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 262 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 7feb9218..d03d69a6 100644 --- a/README.md +++ b/README.md @@ -42,24 +42,47 @@ s.n. dasgupta ### Display the content of the files cat < file1 ## OUTPUT - +``` +chanchal singhvi +c.k. shukla +s.n. dasgupta +sumit chakrobarty +```cmp cat < file2 ## OUTPUT - +``` +anil aggarwal +barun sengupta +c.k. shukla +lalit chowdury +s.n. dasgupta +``` # Comparing Files cmp file1 file2 ## OUTPUT - + ``` +file1 file2 differ: char 1, line 1 +``` + comm file1 file2 ## OUTPUT - +``` +anil aggarwal + barun sengupta + c.k. shukla +chanchal singhvi +c.k. shukla + lalit chowdury + s.n. dasgupta +sumit chakrobarty +``` diff file1 file2 ## OUTPUT - +cutcu #Filters @@ -67,10 +90,10 @@ diff file1 file2 cat > file11 ``` -Hello world +Hello worldcatca This is my world ^d -``` +```>>>> cat > file22 ``` 1001 | Ram | 10000 | HR @@ -82,18 +105,26 @@ cat > file22 cut -c1-3 file11 ## OUTPUT - - - +``` +Hello world +This is my world +``` cut -d "|" -f 1 file22 ## OUTPUT - - +``` +1001 +1002 +1003 +``` cut -d "|" -f 2 file22 ## OUTPUT - +``` +Ram +tom +Joe + ``` cat < newfile ``` @@ -107,39 +138,82 @@ hello world grep Hello newfile ## OUTPUT - +``` +Hello world +``` grep hello newfile ## OUTPUT - +``` +Hello world +``` grep -v hello newfile ## OUTPUT - +``` +Hello world +``` cat newfile | grep -i "hello" ## OUTPUT - +``` +Hello world +hello world +``` cat newfile | grep -i -c "hello" ## OUTPUT - +``` +2 +``` grep -R ubuntu /etc ## OUTPUT - +``` +Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [F +ILE]... + +Search for PATTERN in FILEs (or stdin) + + -H Add 'filename:' prefix + -h Do not add 'filename:' prefix + -n Add 'line_no:' prefix + -l Show only names of files that match + -L Show only names of files that don't match + -c Show only count of matching lines + -o Show only the matching part of line + -q Quiet. Return 0 if PATTERN is found, 1 otherwise + -v Select non-matching lines + -s Suppress open and read errors + -r Recurse + -i Ignore case + -w Match whole words only + -x Match whole lines only + -F PATTERN is a literal (not regexp) + -E PATTERN is an extended regexp + -m N Match up to N times per file + -A N Print N lines of trailing context + -B N Print N lines of leading context + -C N Same as '-A N -B N' + -e PTRN Pattern to match + -f FILE Read pattern from file +``` grep -w -n world newfile ## OUTPUT +``` +1:Hello world +2:hello world +``` cat < newfile @@ -163,60 +237,95 @@ 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 - - +``` +egrep '(^hello)' newfile +``` egrep '(world$)' newfile ## OUTPUT - +``` +Hello world +hello world +``` egrep '(World$)' newfile ## OUTPUT +``` +Linux is best in this World +``` egrep '((W|w)orld$)' newfile ## OUTPUT - +``` +Hello world +hello world +Linux is best in this World +``` egrep '[1-9]' newfile ## OUTPUT +``` +localhost:~# egrep '[1-9]' newfile +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 - +``` +Linux is world number 1 +Unix is predecessor +Linux is best in this World +``` cat > file23 ``` @@ -234,76 +343,160 @@ 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 | HR +``` 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 - - +``` +``` +sed: no address after comma +``` seq 3 | sed '2a hello' ## OUTPUT - +``` +1 +2 +hello +3 +``` seq 2 | sed '2i hello' ## OUTPUT - +``` +1 +2 +hello +3 +localhost:~# seq 2 | sed '2i hello' +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 | Develope +``` sed -n '2,4{s/$/*/;p}' file23 @@ -320,7 +513,13 @@ 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 +532,29 @@ 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