Linux/Unix command Handbook
01/27/2019 Tags: Linux[UPDATED: 2022/02/23]
Purpose
During the period from graduating to being an Engineer, Linux/Unix commands becomes part of my working daily routine. Here, recording several useful and powerful commands to keep in mind.
Linux/Unix command
Table of Contents
SED command
"sed" is used for finding, parsing, text substitution, replacement and text manipulations such as insertion, deletion search etc. And, we also can use sed with regular expression.
$ Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
$
$ -i[SUFFIX], --in-place[=SUFFIX]
$ edit files in place (makes backup if extension supplied).
$ The default operation mode is to break symbolic and hard links.
$ This can be changed with --follow-symlinks and --copy.
$
$ -e script, --expression=script
$ add the script to the commands to be executed
$
$ ...
Example:
- Parsing the strings
- Replacement
- Add a line in a specific position
$ sed -e 's/^..............\(..\)/\1/' nput-file]
$ sed -i 's/abc/123/' [input-file]
$ sed '3iline 3' [input-file]
WC command
"wc" is used for print newline, word, and byte counts for each file.
$ Usage: wc [OPTION]... [FILE]...
$
$ -l, --lines print the newline counts
$ -w, --words print the word counts
$ ...
Example:
- Present the number of lines
$ wc -le [FILE]
LN command
"ln" is an utility for creating links between files. By default, the ln command creates hard links. To create a symbolic links use the -s (–symbolic) option.
$ Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
$ or: ln [OPTION]... TARGET (2nd form)
$ or: ln [OPTION]... TARGET... DIRECTORY (3rd form)
$ or: ln [OPTION]... -t DIRECTORY TARGET... (4th form)
$ ...
$ -s, --symbolic make symbolic links instead of hard links
$ -S, --suffix=SUFFIX override the usual backup suffix
$ -t, --target-directory=DIRECTORY specify the DIRECTORY in which to create
the links
$ ...
Example:
- Creating Symlinks
$ ln -s source_file symbolic_link
SEQ command
“seq” is an utility prints a sequence of numbers, one per line (default), from first (default 1), to near last as possible, in increments of incr (default 1).
$ Usage: :seq [-w] [-f format] [-s string] [-t string] [first [incr]] last
$ -f format Use a printf(3) style format to print each number.
$ -s string Use string to separate numbers.
$ ...
Example:
- Creating a sequence of numbers, one per line in a file
$ seq 100 104 > my_file.txt
=========== To be continued…. ==========
Reference
[2] General help using GNU software
[3] How to Create Symbolic Links in Linux Using the ln Command
Note
If you have any constructive criticism or advises, leave the comments below or feel free to email me @qazqazqaz850@gmail.com. Hope this post will help! :)