CMD Explain
1
# Create symbolic link
2
ln -s /path/to/original /path/to/symlink
3
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
4
└── the path to the original file/folder
5
can use . or ~ or other relative paths
Copied!
1
# Copy directory & contents to another place (-r for recursive)
2
cp -r /path/to/dir /path/to/wheretocopy
Copied!
1
# Preview output of script.
2
# Piping things into less will preview the content
3
curl https://21.co | less
Copied!
1
# Move everything from one dir to another.
2
​
3
# i.e. move all files in Downloads to Desktop. * after folder means select everything
4
mv -v ~/Downloads/* ~/Desktop/
Copied!
1
# Get full path to file
2
realpath <file>
Copied!
1
# Do regex replace (with perl) on a file
2
perl -pi -e "<regex>" <file>
3
​
4
# i.e.
5
perl -pi -e "s/^\s*\{[^\n']*'([^\n']*)'[^\n']*'([^\n#']*)#[^\n']*'[^\n'}]*\},?/'\1', '\2'\n/gm" triggers.js
Copied!
1
# Download URL contents
2
curl -0 <url>
Copied!
1
# Give executable permission to file.
2
chmod a+x <file>
Copied!
1
# Discard output of command.
2
# Will direct ln cmd output to null device that will delete anything written to it.
3
ln > /dev/null
Copied!
1
# See how unicode string is encoded internally.
2
# https://wiki.soimort.org/unix/cli/
3
echo hello | hexdump -C
4
​
5
# See how it is encoded in UTF-16: (assume UTF-8 is default encoding)
6
echo hello | iconv -f utf-8 -t utf-16 | hexdump -C
Copied!
1
# Search for occurrence of word in a file.
2
# i.e. show all occurrences of word fox in file story.txt
3
grep 'fox' story.txt
Copied!
1
# Search whether a string occurs in a directory
2
# -l = print filenames of matching files
3
grep -rl "string" /path
Copied!
Last modified 1yr ago
Copy link