Skip to content

Commit

Permalink
fixed error #47
Browse files Browse the repository at this point in the history
  • Loading branch information
thesilentline committed Jun 19, 2023
1 parent 49310bf commit 7692dad
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
14 changes: 7 additions & 7 deletions shell/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ esac

# TODO: Add grep
# grep_example.txt is an example file you can create your own file and give its name instead of grep_example.txt to search in that file.
grep "grep" grep_example.txt # change the keyword inside the bracket to search for different words it will print the whole line if the given keyword is in that line.
grep --color "to" grep_example.txt # it will print the line which have "to" keyword in them, and --color is used to highlite the text.
grep -i "it" grep_example.txt # -i will Ignore case sensitivity
grep -c "the" grep_example.txt # -c will count the number of occurrences of the given string in the text.
grep -v "the" grep_example.txt # it will print all the lines which DO NOT have the given string.
grep "grep" data/grep_example.txt # change the keyword inside the bracket to search for different words it will print the whole line if the given keyword is in that line.
grep --color "to" data/grep_example.txt # it will print the line which have "to" keyword in them, and --color is used to highlite the text.
grep -i "it" data/grep_example.txt # -i will Ignore case sensitivity
grep -c "the" data/grep_example.txt # -c will count the number of occurrences of the given string in the text.
grep -v "the" data/grep_example.txt # it will print all the lines which DO NOT have the given string.

# REGEX in grep
# ^ Matches characters at the beginning of a line
Expand All @@ -68,8 +68,8 @@ grep -v "the" grep_example.txt # it will print all the lines which DO NOT have
# [a-z] Matches any characters between A and Z
# [^ ..] Matches anything apart from what is contained in the brackets

grep ^T grep_example.txt # lines starting with T.
grep t$ grep_example.txt # To display lines that end with the letter ‘t’ run
grep ^T data/grep_example.txt # lines starting with T.
grep t$ data/grep_example.txt # To display lines that end with the letter ‘t’ run

grep --help # Getting help with more Grep options

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions shell/examples/file_list.txt

This file was deleted.

2 changes: 1 addition & 1 deletion shell/examples/list.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
output_file="file_list.txt"

#Then, we use the ls command with the *.txt pattern to list all .txt files in the current directory. The > operator redirects the output of the ls command to the specified output file.
ls *.txt > "$output_file"
ls ../data/*.txt > "$output_file"

# Finally, we display a message indicating the completion of the task, specifying the name of the output file.
echo "List of .txt files has been saved to $output_file"
Expand Down

0 comments on commit 7692dad

Please sign in to comment.