Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 2.45 KB

07132022.md

File metadata and controls

78 lines (57 loc) · 2.45 KB
  1. Comparison between DOS and Linux/UNIX:

Link: How to create Markdown Table

DOS Linux/UNIX
cd cd
attrib chmod
comp diff
copy cp
del rm
rd rmdir
dir ls
set printenv
find grep
help man
md mkdir
move mv
ren (rename) mv
date, time date
chkdsk df
type cat
type <filename> | more more
sort sort
  • Example:
dir | sort /R
  1. Some grep examples integrated with find and globstar: **:
  • NOTE:

    • glob ~ *: was called as GLOB expression.
    • If Bash version is 4 or higher, can make use of Bash’s globstar (**) to match files recursively.
  • exp1: Using grep with --include=Glob, search for the pattern only with the .log/.md extension recursively in the test/ folder:

grep -R --include=*.log 'Exception' test/
grep -R --include=*.{log,md} 'Exception' test/
  • exp2: With globstar expression, the -R recursive option is now totally useless:
grep 'Exception' test/**/*.log
grep 'Exception' test/**/*.{log,md}
  • exp3: Only using find command with the example filename pattern "app_20200301.log":
find test/ -type f -a -regextype 'egrep' -regex '.*_[0-9]{8}.*'
  • exp4: Combining the find with grep in one command with the -exec action:
find test/ -type f -a -regextype 'egrep' -regex '.*_[0-9]{8}.*' -exec grep -H "Exception" '{}' \;
  • NOTE (exp4):

    • The command requires the ending \;. This is because it indicates the termination of the grep command.
    • The -exec action will be executed on each file the find command has found.
  • exp5: Using xargs to combine find and grep:

find test/ -type f -a -regextype 'egrep' -regex '.*_[0-9]{8}.*' | xargs grep "Exception"
  • NOTE (exp5):

    • xargs will build matched files into bundles and run them through the command as few times as possible.