DEV Community

Kaziu
Kaziu

Posted on β€’ Edited on

3 2

πŸ“– 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

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay