Bash Commands
Posted adelaide
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bash Commands相关的知识,希望对你有一定的参考价值。
Command | Description |
---|---|
awk | "Aho, Weinberger and Kernigan", Bell Labs, 1970s. Interpreted programming language for text processing. |
awk -F | (see above) + Set the field separator. |
cat | Display the contents of a file at the command line, is also used to copy and or append text files into a document. Named after its function to con-cat-enate files. |
cd | Change the current working directory. Also known as chdir (change directory). |
cd / | Change the current directory to root directory. |
cd .. | Change the current directory to parent directory. |
cd ~ | Change the current directory to your home directory. |
cp | Make copies of files and directories. |
cp -r | Copy directories recursively. |
cut | Drop sections of each line of input by bytes, characters, or fields, separated by a delimiter (the tab character by default). |
cut -d -f | -d is for delimiter instead of tab character, -f select only those fields (ex.: “cut -d “,“ -f1 multilined_file.txt” - will mean that we select only the first field from each comma-separated line in the file) |
du | Estimate (and display) the file space usage - space used under a particular directory or files on a file system. |
df | Display the amount of available disk space being used by file systems. |
df -h | Use human readable format. |
free | Display the total amount of free and used memory (use vm_stat instead on MacOS). |
free -m | Display the amount of memory in megabytes. |
free -g | Display the amount of memory in gigabytes. |
grep | Process text and print any lines which match a regular expression ("global regular expression print") |
head | Print the beginning of a text file or piped data. By default, outputs the first 10 lines of its input to the command line. |
head -n | Output the first n lines of input data (ex.: “head -5 multilined_file.txt”). |
kill | Send a signal to kill a process. The default signal for kill is TERM (which will terminate the process). |
less | Is similar to more, but has the extended capability of allowing both forward and backward navigation through the file. |
ls | List the contents of a directory. |
ls -l | List the contents of a directory + use a long format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified date and filename. |
ls -lh | List the contents of a directory + print sizes in human readable format. (e.g. 1K, 234M, 2G, etc.) |
ls -lS | Sort by file size |
man | Display the manual pages which provide documentation about commands, system calls, library routines and the kernel. |
mkdir | Create a directory on a file system ("make directory") |
more | Display the contents of a text file one screen at a time. |
mv | Rename files or directories or move them to a different directory. |
nice | Run a command with a modified scheduling priority. |
ps | Provide information about the currently running processes, including their process identification numbers (PIDs) ("process status"). |
ps a | Select all processes except both session leaders and processes not associated with a terminal. |
pwd | Abbreviated from "print working directory", pwd writes the full pathname of the current working directory. |
rm | Remove files or directories. |
rm -r | Remove directories and their contents recursively. |
sort | Sort the contents of a text file. |
sort -r | Sort the output in the reverse order. Reverse means - to reverse the result of comparsions |
sort -k | -k or --key=POS1[,POS2] Start a key at POS1 (origin 1), end it at POS2 (default end of the line) (ex.: “sort -k2,2 multilined_file.txt”). |
sort -n | Compare according to string numerical value. |
tail | Print the tail end of a text file or piped data. Be default, outputs the last 10 lines of its input to the command line. |
tail -n | Output the last n lines of input data (ex.: “tail -2 multilined_file.txt”). |
top | Produce an ordered list of running processes selected by user-specified criteria, and updates it periodically. |
touch | Update the access date and or modification date of a file or directory or create an empty file. |
tr | Replace or remove specific characters in its input data set ("translate"). |
tr -d | Delete characters, do not translate. |
vim | Is a text editor ("vi improved"). It can be used for editing any kind of text and is especially suited for editing computer programs. |
wc | Print a count of lines, words and bytes for each input file ("word count") |
wc -c | Print only the number of characters. |
wc -l | Print only the number of lines. |
以上是关于Bash Commands的主要内容,如果未能解决你的问题,请参考以下文章
markdown [Bash配置] bash文件配置供参考#bash #linux