Common Linux commands (MIT: Shell Tools and Scripting)

(1) Command:         

1. Select all command *         eg.           rm * (delete all files)

2. Cat merge and print eg. cat <(ls) <(ls ..) (note that there must be a space before <)

3.ls command             eg.        

ls -lhat --color=auto (Each parameter can only have one space, two spaces cannot be recognized)
(For detailed functions, see man ls)

3.rm -rf (delete non-empty directories)

-r means to recurse downward, no matter how many levels of directories there are, delete them all;
-f means to force the deletion directly without any prompt.

4.sudo passwd root (set password when switching ROOT users)

Then su can switch

(2)Extension:

1. Create multiple files       

touch test{,1,2}        ==  test1 test2

touch test{1..9}        ==  test1 .. test9

(3)Variables

(Note that when printing variables, use "", and print "'' as is):

1. Print command results  
  echo "$(ls)"

test
test1
test1..9
test2
test3
test4
test5
test6
test7
test8
test9

2.$_

(4)Script function:

1.eg.marco.sh

#!/bin/bash
marco(){

     echo "$(pwd)">/home/usr/Documents/path.txt

}
lms

Use source marco.sh to make the marco function available globally

./marco.sh Load marco function definition

To call a function, enter the function name directly (if there are parameters, follow the function name)

Guess you like

Origin blog.csdn.net/2301_79140115/article/details/134954944