Some useful linux commands( continually updated)

Counting number of folders or files in a specific directory

Using find command

find /directory/ -maxdepth 1 -type d -print | wc -l
The additional 1 count is there due the the current directory ‘.’ , which is also taken into account by find, i.e. , find is also printing the directory itself.

$ find /home/dir/ -maxdepth 1 -type d -print | wc -l
12345

So the number of files in the /home/dir/ is 12344.

For more info, please go to this

Copy the folder to another folder

$ cp -r source_path destination_path

Compile c++ files in terminal

Suppose your source code name is main.cpp:

g++ main.cpp -o main
  • g++ is the invocation of the C++ component of GCC, the defacto compiler for C/C++ and whole host of other languages on the Linux platform. It’s currently the only compiler capable of compiling the Linux kernel.
  • main.cpp is the c++ source file you wish to compile.
  • -o main specifies the name of the output file you wish to create once the source is compiled. The target source file and the target output file can be inverted if you wish, so g++ -o main main.cpp is equally valid.
  • To then execute that program, you need to do ./main in the terminal.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值