Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize file/directory placeholders #207

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ab
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To send 100 requests with a concurency of 50 requests to a URL:
ab -n 100 -c 50 <url>
ab -n 100 -c 50 "<url>"

# To send requests for 30 seconds with a concurency of 50 requests to a URL:
ab -t 30 -c 50 <url>
ab -t 30 -c 50 "<url>"
22 changes: 11 additions & 11 deletions acl
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Get ACL
getfacl <file>
getfacl "<path/to/file>"

# Add or modify ACL on file
setfacl -m u:username:rX <file>
setfacl -m g:groupname:rw <file>
setfacl -m o::- <file>
setfacl -m u:username:rX "<path/to/file>"
setfacl -m g:groupname:rw "<path/to/file>"
setfacl -m o::- "<path/to/file>"

# or provide all permissions at once
setfacl -m u::rwx,g:groupname:rX,o::- <file>
setfacl -m u::rwx,g:groupname:rX,o::- "<path/to/file>"

# Copy ACL from file-A to file-B
getfacl file-A | setfacl -M - file-B

# Apply ACL recursivelly to directory
setfacl -R -m u:username:rX <directory>
setfacl -R -m u:username:rX "<path/to/directory>"

# Delete ACL
setfacl -x u:username,g:groupname <file>
setfacl -x u:username,g:groupname "<path/to/file>"

# Delete all ACL on file, including default
setfacl -b <file>
setfacl -b "<path/to/file>"

# Same operations works for default ACLs
setfacl -m d:u:username:rx <directory>
setfacl -x d:u:username <directory>
setfacl -m d:u:username:rx "<path/to/directory>"
setfacl -x d:u:username "<path/to/directory>"

# Delete only default ACLs
setfacl -k <directory>
setfacl -k "<path/to/directory>"
4 changes: 2 additions & 2 deletions ag
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# To exclude a directory from a search:
ag <phrase> --ignore-dir=<dir>
ag <phrase> --ignore-dir="<path/to/directory>"

# To exclude a file from a search:
ag <phrase> --ignore=<file>
ag <phrase> --ignore="<path/to/file>"

# To force colorization:
ag <phrase> --color | less -R
Expand Down
4 changes: 2 additions & 2 deletions aria2c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# To download a file:
# The url can be a http(s), ftp, .torrent file or even a magnet link
aria2c <url>
aria2c "<url>"

# To prevent downloading the .torrent file:
aria2c --follow-torrent=mem <url>
aria2c --follow-torrent=mem "<url>"

# Download 1 file at a time (-j)
# continuing (-c) any partially downloaded ones
Expand Down
6 changes: 3 additions & 3 deletions bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Display a single file on the terminal:
bat <file>
bat "<path/to/file>"

# Display multiple files at once:
bat <file> <file>
bat "<path/to/file>" "<path/to/file>"

# Show and highlight non-printable characters:
bat -A <file>
bat -A "<path/to/file>"

# Display all supported languages:
bat --list-languages
Expand Down
6 changes: 3 additions & 3 deletions cat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# To display the contents of a file:
cat <file>
cat "<path/to/file>"

# To display file contents with line numbers
cat -n <file>
cat -n "<path/to/file>"

# To display file contents with line numbers (blank lines excluded)
cat -b <file>
cat -b "<path/to/file>"
12 changes: 6 additions & 6 deletions chown
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Change a file's owner:
chown <user> <file>
chown <user> "<path/to/file>"

# Change a file's owner and group:
chown <user>:<group> <file>
chown <user>:<group> "<path/to/file>"

# Set user to match group value
chown <user>: <file>
chown <user>: "<path/to/file>"

# Set group to match user value
chown :<group> <file>
chown :<group> "<path/to/file>"

# Change a directory's owner recursively:
chown -R <user> <directory>
chown -R <user> "<path/to/directory>"

# Change ownership to match another file:
chown --reference=<reference-file> <file>
chown --reference=<reference-file> "<path/to/file>"
4 changes: 2 additions & 2 deletions csplit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To split a file based on a pattern:
csplit <file> '/PATTERN/'
csplit "<path/to/file>" '/PATTERN/'

# To use prefix/suffix to improve output file names:
csplit -f 'prefix-' -b '%d.extension' <file> '/PATTERN/' '{*}'
csplit -f 'prefix-' -b '%d.extension' "<path/to/file>" '/PATTERN/' '{*}'
2 changes: 1 addition & 1 deletion cups
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
http://localhost:631 (in web browser)

# To print a file:
lp <file>
lp "<path/to/file>"

# To display the print queue:
lpq
Expand Down
14 changes: 7 additions & 7 deletions curl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# To download a file:
curl <url>
curl "<url>"

# To download and rename a file:
curl <url> -o <outfile>
curl "<url>" -o <outfile>

# To download multiple files:
curl -O <url> -O <url>
curl -O "<url>" -O "<url>"

# To download all sequentially numbered files (1-24):
curl http://example.com/pic[1-24].jpg

# To download a file and pass HTTP authentication:
curl -u <username>:<password> <url>
curl -u <username>:<password> "<url>"

# To download a file with a proxy:
curl -x <proxy-host>:<port> <url>
curl -x <proxy-host>:<port> "<url>"

# To download a file over FTP:
curl -u <username>:<password> -O ftp://example.com/pub/file.zip
Expand All @@ -23,10 +23,10 @@ curl -u <username>:<password> -O ftp://example.com/pub/file.zip
curl ftp://username:[email protected]

# To resume a previously failed download:
curl -C - -o <partial-file> <url>
curl -C - -o <partial-file> "<url>"

# To fetch only the HTTP headers from a response:
curl -I <url>
curl -I "<url>"

# To fetch your external IP and network info as JSON:
curl http://ifconfig.me/all.json
Expand Down
2 changes: 1 addition & 1 deletion dnf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dnf provides <executable>
dnf download <package>

# To install the build dependencies for a SRPM or from a .spec file:
dnf builddep <file>
dnf builddep "<path/to/file>"

# List installed packages
dnf list installed
2 changes: 1 addition & 1 deletion fd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
fd <search query>

# Specifying the root directory for the search:
fd <search query> <directory>
fd <search query> "<path/to/directory>"

# Searching for a particular file extension:
fd -e <file extension> <search query>
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To print file metadata:
ffmpeg -i <file>
ffmpeg -i "<path/to/file>"

# To convert all m4a files to mp3
for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -vn -b:a 320k "${f%.m4a}.mp3"; done
Expand Down
4 changes: 2 additions & 2 deletions find
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ find . -type f -perm 777
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l

# To find files newer than 1 day old and copy elsewhere (remove -p flag in xargs to not be asked):
find . -type f -ctime -1 -print0 | xargs -0 -p cp -t <dir>
find . -type f -ctime -1 -print0 | xargs -0 -p cp -t "<path/to/directory>"
# or:
find . -type f -ctime -1 -print0 | xargs -0 -p -J % cp % <dir>
find . -type f -ctime -1 -print0 | xargs -0 -p -J % cp % "<path/to/directory>"

# To find files with extension '.txt' and remove them:
find ./path/ -name '*.txt' -delete
Expand Down
2 changes: 1 addition & 1 deletion fmt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# To format lines, 50 words in each line:
cat <file> | fmt -w 50
cat "<path/to/file>" | fmt -w 50
6 changes: 3 additions & 3 deletions gdb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ b, break <function>

# To set a (conditional) breakpoint at a general location:
b, break <loc> [if <condition>]
with <loc> as <function>|<file>:<line>|<line>|*<address>|-offset|+offset
with <loc> as <function>|"<path/to/file>":<line>|<line>|*<address>|-offset|+offset

# To set a watchpoint, i.e., stop when expression changes its value:
watch <expr>
Expand All @@ -21,7 +21,7 @@ info breakpoints, info watchpoints
clear, delete
delete <num>
clear <loc>
with <loc> as <function>|<file>:<line>|<line>|*<address>|-offset|+offset
with <loc> as <function>|"<path/to/file>":<line>|<line>|*<address>|-offset|+offset

# To disable a breakpoint:
dis, disable <num>
Expand All @@ -47,7 +47,7 @@ ni, nexti

# To run until given location is reached
advance <loc>
with <loc> as <function>|<file>:<line>|<line>|*<address>|-offset|+offset
with <loc> as <function>|"<path/to/file>":<line>|<line>|*<address>|-offset|+offset

# To run until function ends, i.e., jump out of a function:
fin, finish
Expand Down
2 changes: 1 addition & 1 deletion git
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ git branch --merged | egrep -v "(^*|main|dev)" | xargs git branch -d
git branch -u upstream/foo

# To see who commited which line in a file:
git blame <file>
git blame "<path/to/file>"

# To sync a fork with the master repo:
git remote add upstream [email protected]:<username>/<repo>.git # Set a new repo
Expand Down
22 changes: 11 additions & 11 deletions grep
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# To search a file for a pattern:
grep <pattern> <file>
grep <pattern> "<path/to/file>"

# To perform a case-insensitive search (with line numbers):
grep -in <pattern> <file>
grep -in <pattern> "<path/to/file>"

# To recursively grep for string <pattern> in <dir>:
grep -R <pattern> <dir>
# To recursively grep for string <pattern> in "<path/to/directory>":
grep -R <pattern> "<path/to/directory>"

# Read search patterns from a file (one per line):
grep -f <pattern-file> <file>
grep -f <pattern-file> "<path/to/file>"

# Find lines NOT containing pattern:
grep -v <pattern> <file>
grep -v <pattern> "<path/to/file>"

# Set how many lines to show before (-B) and after (-A) pattern:
grep -B 3 -A 2 <pattern> <file>
grep -B 3 -A 2 <pattern> "<path/to/file>"

# To grep with regular expressions:
grep "^00" <file> # Match lines starting with 00
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" <file> # Find IP add
grep "^00" "<path/to/file>" # Match lines starting with 00
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" "<path/to/file>" # Find IP add

# To find all files that match <pattern> in <dir>
grep -rnw <dir> -e <pattern>
# To find all files that match <pattern> in "<path/to/directory>"
grep -rnw "<path/to/directory>" -e <pattern>

# To exclude grep from your grepped output of ps:
# (Add [] to the first letter. Ex: sshd -> [s]shd)
Expand Down
12 changes: 6 additions & 6 deletions head
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# To show the first 10 lines of <file>:
head <file>
# To show the first 10 lines of "<path/to/file>":
head "<path/to/file>"

# To show the first <number> lines of <file>:
head -n <number> <file>
# To show the first <number> lines of "<path/to/file>":
head -n <number> "<path/to/file>"

# To show the first <number> bytes of <file>:
head -c <number> <file>
# To show the first <number> bytes of "<path/to/file>":
head -c <number> "<path/to/file>"
6 changes: 3 additions & 3 deletions hg
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ tags: [ vcs ]
hg clone

# To add files to hg tracker:
hg add <file>
hg add "<path/to/file>"

# To add all files in <dir> to hg tracker:
hg add <dir>
# To add all files in "<path/to/directory>" to hg tracker:
hg add "<path/to/directory>"

# To create a commit with all tracked changes and a message:
hg commit -m <message>
Expand Down
16 changes: 8 additions & 8 deletions ls
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# To display everything in <dir>, excluding hidden files:
ls <dir>
# To display everything in "<path/to/directory>", excluding hidden files:
ls "<path/to/directory>"

# To display everything in <dir>, including hidden files:
ls -a <dir>
# To display everything in "<path/to/directory>", including hidden files:
ls -a "<path/to/directory>"

# To display all files, along with the size (with unit suffixes) and timestamp:
ls -lh <dir>
ls -lh "<path/to/directory>"

# To display files, sorted by size:
ls -S <dir>
ls -S "<path/to/directory>"

# To display directories only:
ls -d */ <dir>
ls -d */ "<path/to/directory>"

# To display directories only, include hidden:
ls -d .*/ */ <dir>
ls -d .*/ */ "<path/to/directory>"

# To display all files sorted by changed date, most recent first:
ls -ltc
Expand Down
4 changes: 2 additions & 2 deletions more
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# To show <file> beginning at line number 5:
more +5 <file>
# To show "<path/to/file>" beginning at line number 5:
more +5 "<path/to/file>"
2 changes: 1 addition & 1 deletion mv
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ mv -i <src> <dest>
mv -n <src> <dest>

# To move listed file(s) to a directory
mv -t <dest> <file>...
mv -t <dest> "<path/to/file>"...
12 changes: 6 additions & 6 deletions ncdu
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# To save results to <file>:
ncdu -o <file>
# To save results to "<path/to/file>":
ncdu -o "<path/to/file>"

# To read from <file>:
ncdu -f <file>
# To read from "<path/to/file>":
ncdu -f "<path/to/file>"

# To save results to a compressed file:
ncdu -o- | gzip > <file>
ncdu -o- | gzip > "<path/to/file>"

# To read from a compressed file:
zcat <file> | ncdu -f-
zcat "<path/to/file>" | ncdu -f-
Loading