linux_common - JasonWayne/personal-wiki GitHub Wiki

Commands

xargs

# Basic Usage
ls *.txt | xargs -n1 -I cp {} /tmp

# remove files
## see https://www.thegeekstuff.com/2013/12/xargs-examples/
find . -name "*.c" -print0 | xargs -0 rm -rf

http://man.linuxde.net/xargs https://www.thegeekstuff.com/2013/12/xargs-examples/

Tips

<<<, <<的含义

参考 https://askubuntu.com/questions/678915/whats-the-difference-between-and-in-bash https://unix.stackexchange.com/questions/80362/what-does-mean <<<: "Here String" <<: "Here Document"

$ wc << EOF
> one two three
> four five
> EOF
 2  5 24

# read first second <<< "hello world"
# echo $first
hello
# echo $second
world

FAQ

/etc/profile和bashrc的关系 http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/

Dash in the shell

https://unix.stackexchange.com/questions/41828/what-does-dash-at-the-end-of-a-command-mean

Frequently used

Find files and deleted

find . -type f -name '*.txt' | xargs rm

Execute sed in a directory recursively

# windows 慎用
find . -type f -not -path '*/.*' | xargs -I {} sed -i 's/org.springframework/qazwsx/g' {}

Tricks

Ctrl + R: reverse-i(increment)-search. Press Ctrl + R again to scroll.