Merge pull request #39 from ashleyharvey/readme-changes

Readme changes
This commit is contained in:
Robert Chang
2020-02-26 00:54:51 +11:00
committed by GitHub

View File

@@ -71,6 +71,12 @@ cp readme.txt documents/
```shell ```shell
cp readme.txt readme.bak.txt cp readme.txt readme.bak.txt
``` ```
More advanced:
```shell
cp readme{,.bak}.txt
# Note: learn how the {} works with touch foo{1,2,3}.txt and
see what happens.
```
## copy a folder ## copy a folder
@@ -135,7 +141,7 @@ mv myMedia/ myMusic/
**STOP DRAG AND DROPING TO MERGE FOLDERS** :-1: **STOP DRAG AND DROPING TO MERGE FOLDERS** :-1:
```shell ```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 ## create a new file
@@ -143,9 +149,9 @@ rsync -a /images/ /images2/
**STOP RIGHT CLICKING AND CREATE A NEW FILE** :-1: **STOP RIGHT CLICKING AND CREATE A NEW FILE** :-1:
```shell ```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 # or
> 'new file' # erase the content if it already exists > 'new file' # note: erases the content if it already exists
``` ```
## create a new folder ## create a new folder
@@ -155,7 +161,7 @@ touch 'new file' # updates the file's access and modification timestamp if it al
```shell ```shell
mkdir 'untitled folder' mkdir 'untitled folder'
# or # or
mkdir -p 'path/may/not/exist/untitled folder' mkdir -p 'path/may/not/exist/untitled\ folder'
``` ```
## show file/folder size ## show file/folder size
@@ -171,7 +177,8 @@ du -sh node_modules/
**STOP RIGHT CLICKING AND SHOW FILE/FOLDER INFO** :-1: **STOP RIGHT CLICKING AND SHOW FILE/FOLDER INFO** :-1:
```shell ```shell
stat -x readme.md stat -x readme.md # on macOS
stat readme.md # on Linux
``` ```
## open a file with the default program ## open a file with the default program
@@ -232,7 +239,9 @@ rm -r my_useless_folder
**STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1: **STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1:
```shell ```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.
ls -alrth my_folder # -r: reverse output. -t: sort by time (modified). -h: output human-readable sizes.
``` ```
## tree view a folder and its subfolders ## tree view a folder and its subfolders
@@ -240,8 +249,9 @@ ls -la my_folder
**STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1: **STOP OPENING YOUR FINDER OR FILE EXPLORER** :-1:
```shell ```shell
tree # on Linux tree # on Linux
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS
# Note: install homebrew (https://brew.sh) to be able to use (some) Linux utilities such as tree.
``` ```
## find a stale file ## find a stale file
@@ -282,8 +292,8 @@ date +%m/%d/%Y
What about a week from now? What about a week from now?
```shell ```shell
date -d "+7 days" # on Linux date -d "+7 days" # on Linux
date -j -v+7d # on MacOS date -j -v+7d # on MacOS
``` ```
## use a calculator ## use a calculator
@@ -316,6 +326,8 @@ ping umair.surge.sh
```shell ```shell
cat apps/settings.py cat apps/settings.py
# 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
``` ```
## search for a text ## search for a text
@@ -323,7 +335,7 @@ cat apps/settings.py
**STOP CMD/CTRL + F IN A FOLDER** :-1: **STOP CMD/CTRL + F IN A FOLDER** :-1:
```shell ```shell
grep -ir "Query" file.txt grep -i "Query" file.txt
``` ```
![grep](./grep.jpg) ![grep](./grep.jpg)
@@ -334,6 +346,7 @@ grep -ir "Query" file.txt
```shell ```shell
imgcat image.png imgcat image.png
# Note: requires iTerm2 terminal.
``` ```
## show disk size ## show disk size