From 6acd4c52e395682e073962638095182b135c88ab Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 15:21:35 -0800 Subject: [PATCH 1/7] Initial changes! --- readme.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 95c2724..15c7627 100644 --- a/readme.md +++ b/readme.md @@ -71,6 +71,10 @@ cp readme.txt documents/ ```shell cp readme.txt readme.bak.txt ``` +More advanced: +```shell +cp readme{.bak}.txt +``` ## copy a folder @@ -135,7 +139,7 @@ mv myMedia/ myMusic/ **STOP DRAG AND DROPING TO MERGE FOLDERS** :-1: ```shell -rsync -a /images/ /images2/ +rsync -a /images/ /images2/ # note: may over-write files with the same name, so be careful! ``` ## create a new file @@ -143,9 +147,9 @@ rsync -a /images/ /images2/ **STOP RIGHT CLICKING AND CREATE A NEW FILE** :-1: ```shell -touch 'new file' # updates the file's access and modification timestamp if it already exists +touch 'new file' # updates the file's access and modification timestamp if it already exists # or -> 'new file' # erase the content if it already exists +> 'new file' # note: erases the content if it already exists ``` ## create a new folder @@ -155,7 +159,7 @@ touch 'new file' # updates the file's access and modification timestamp if it al ```shell mkdir 'untitled folder' # or -mkdir -p 'path/may/not/exist/untitled folder' +mkdir -p 'path/may/not/exist/untitled\ folder' ``` ## show file/folder size @@ -171,7 +175,8 @@ du -sh node_modules/ **STOP RIGHT CLICKING AND SHOW FILE/FOLDER INFO** :-1: ```shell -stat -x readme.md +stat -x readme.md # on macOS +stat readme.md # on Linux ``` ## open a file with the default program @@ -232,7 +237,8 @@ rm -r my_useless_folder **STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1: ```shell -ls -la my_folder +ls my_folder # Simple +ls -la my_folder # -l: show in list format. -a: show all files, including hidden. -la combines those options. ``` ## tree view a folder and its subfolders @@ -240,8 +246,9 @@ ls -la my_folder **STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1: ```shell -tree # on Linux -find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS +tree # on Linux +find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS +# Note: install homebrew (brew.sh) to be able to use (some) Linux utilities such as tree. ``` ## find a stale file @@ -282,8 +289,8 @@ date +%m/%d/%Y What about a week from now? ```shell -date -d "+7 days" # on Linux -date -j -v+7d # on MacOS +date -d "+7 days" # on Linux +date -j -v+7d # on MacOS ``` ## use a calculator @@ -316,6 +323,8 @@ ping umair.surge.sh ```shell cat apps/settings.py +# or, if the file is too big, you can take its output and push it through a 'pager' which shows you one page at a time. +cat apps/settings.py | less ``` ## search for a text From 7c0e58b9086c9e24f53bd64a547d384af6092936 Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 15:22:19 -0800 Subject: [PATCH 2/7] Remove r flag from grep: that's for recursion as far as I can tell, not required when grepping a file. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 15c7627..ae377b1 100644 --- a/readme.md +++ b/readme.md @@ -332,7 +332,7 @@ cat apps/settings.py | less **STOP CMD/CTRL + F IN A FOLDER** :-1: ```shell -grep -ir "Query" file.txt +grep -i "Query" file.txt ``` ![grep](./grep.jpg) From 67746fcc4dfe83d64041b7d620aa4394c70611ea Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 15:23:35 -0800 Subject: [PATCH 3/7] Add note about imgcat. --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index ae377b1..e6d7658 100644 --- a/readme.md +++ b/readme.md @@ -343,6 +343,7 @@ grep -i "Query" file.txt ```shell imgcat image.png +# Note: requires iTerm2 terminal. ``` ## show disk size From 35abb5b2895a8a302d65da3ca041bfaa81ab6e8a Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 15:35:51 -0800 Subject: [PATCH 4/7] Formatting. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e6d7658..38ac221 100644 --- a/readme.md +++ b/readme.md @@ -149,7 +149,7 @@ rsync -a /images/ /images2/ # note: may over-write files with the same name, so ```shell touch 'new file' # updates the file's access and modification timestamp if it already exists # or -> 'new file' # note: erases the content if it already exists +> 'new file' # note: erases the content if it already exists ``` ## create a new folder From b6f677723610a38c40d6269a6613dfea70b8859d Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 15:38:01 -0800 Subject: [PATCH 5/7] More formatting. --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 38ac221..e786b04 100644 --- a/readme.md +++ b/readme.md @@ -248,7 +248,7 @@ ls -la my_folder # -l: show in list format. -a: show all files, including hid ```shell tree # on Linux find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS -# Note: install homebrew (brew.sh) to be able to use (some) Linux utilities such as tree. +# Note: install homebrew (https://brew.sh) to be able to use (some) Linux utilities such as tree. ``` ## find a stale file @@ -323,7 +323,7 @@ ping umair.surge.sh ```shell cat apps/settings.py -# or, if the file is too big, you can take its output and push it through a 'pager' which shows you one page at a time. +# if the file is too big to fit on one page, you can send it to a 'pager' (less) which shows you one page at a time. cat apps/settings.py | less ``` From dec70a88eaddd0af84f38d955c28707c582d1e81 Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 15:39:57 -0800 Subject: [PATCH 6/7] Clean up the {} syntax and add a note about it. --- readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index e786b04..6fce724 100644 --- a/readme.md +++ b/readme.md @@ -73,7 +73,9 @@ cp readme.txt readme.bak.txt ``` More advanced: ```shell -cp readme{.bak}.txt +cp readme{,.bak}.txt +# Note: learn how the {} works with touch foo{1,2,3}.txt and +see what happens. ``` ## copy a folder From 623a30b54d891d27749d721f423abec6cc02ce13 Mon Sep 17 00:00:00 2001 From: Ashley Harvey Date: Sun, 23 Feb 2020 16:25:15 -0800 Subject: [PATCH 7/7] Added ls -alrth and comments. --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 6fce724..5a5970d 100644 --- a/readme.md +++ b/readme.md @@ -241,6 +241,7 @@ rm -r my_useless_folder ```shell ls my_folder # Simple ls -la my_folder # -l: show in list format. -a: show all files, including hidden. -la combines those options. +ls -alrth my_folder # -r: reverse output. -t: sort by time (modified). -h: output human-readable sizes. ``` ## tree view a folder and its subfolders