DEV Community

Kaziu
Kaziu

Posted on • Updated on

📖 My Linux commands diary

I'll write commands which I will have used in real life, like diary. If you want to write your commands in your life, please comment it


😎 search big image files (bigger than 100kb) in assets directory !

ls -lh thanks for "h", human can see file size easily
For example 168075 -> 164kb

$ find ./hoge/apps/web/src/assets -size +100kb | xargs ls -lh | sort -rn
-rw-r--r--@ 1 kaziu  staff   164K Apr  9 08:32 ./hoge/apps/web/src/assets/hoge1.svg
-rw-r--r--  1 kaziu  staff   336K Apr  9 08:32 ./hoge/apps/web/src/assets/hoge2.svg
-rw-r--r--  1 kaziu  staff   280K Apr  9 08:32 ./hoge/apps/web/src/assets/hoge3.svg
Enter fullscreen mode Exit fullscreen mode

😎 How many lines of "INSERT" in log file?

-l means lines, count of new llines

$ grep INSERT log/development.log | wc -l
2940
Enter fullscreen mode Exit fullscreen mode

😎 I need to delete all files except some files

I'm gonna delete all files, but I still need these files docker-compose.yml, Dockerfile, Gemfile, Gemfile.lock !!

grep -v
v option means 'except'

# (la is alias of ls -la on my PC)
$ la | grep -v -E 'docker-compose.yml|Dockerfile|Gemfile|Gemfile.lock|entrypoint.sh' | xarg
s rm -rf
Enter fullscreen mode Exit fullscreen mode

Top comments (0)