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

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

$ ls
this_has_text_to_find_1.txt
this_has_text_to_find_2.txt
this_has_text_to_find_3.txt
this_has_text_to_find_4.txt

$ rename 's/text_to_find/been_renamed/' *.txt
$ ls
this_has_been_renamed_1.txt
this_has_been_renamed_2.txt
this_has_been_renamed_3.txt
this_has_been_renamed_4.txt

How to list only subdirectories in the current one ?

ls -d */
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值