一些有用的bash命令记录汇总

来源:互联网 发布:淘宝店哪家衣服质量好 编辑:程序博客网 时间:2024/05/22 07:03

Renaming/moving files with suffixes quickly:

cp /home/foo/realllylongname.cpp{,-old}

This expands to:

cp /home/foo/realllylongname.cpp /home/foo/realllylongname.cpp-old

Just to point out that to do the reverse (going from .cpp-old to .cpp) you’d do

cp /home/foo/realllylongname.cpp{-old,} 

Repeats your last command

!!

Most useful in the form:

sudo !!

‘^string^string2’ which takes the last command, replaces string with string2 and executes it

sodu apt-install java^sodu^sudo

rename

$ lsthis_has_text_to_find_1.txtthis_has_text_to_find_2.txtthis_has_text_to_find_3.txtthis_has_text_to_find_4.txt$ rename 's/text_to_find/been_renamed/' *.txt$ lsthis_has_been_renamed_1.txtthis_has_been_renamed_2.txtthis_has_been_renamed_3.txtthis_has_been_renamed_4.txt

How to list only subdirectories in the current one ?

ls -d */
0 0
原创粉丝点击