Blog Archives

5 Find Oneliners for removing all the empty files with a certain extension

All this 5 oneliners do the same thing. Remove the empty files with a certain extension (.txt in my example), with the Linux and Unix powerfull find command: One: $ find /path/to/dir -type f -name ‘*.txt’ -empty -exec rm {}

Tagged with: , , , , , ,
Posted in The Linux and Unix Articles!

Awk Trick: Verify the /etc/passwd Lines

As you know, the /etc/passwd file has 7 fields on each line. The lines from /etc/passwd having more than 7 fields can create security vulnerabilities or generate massive system errors. It is better to remove them This little awk oneliner

Tagged with: , , , , , , , ,
Posted in The Linux and Unix Articles!

Oneliner: Count How Many Times a String Appears in a File

When working with text files, it is usefull to know how to count how many times a string appears in a file. To do that, use this oneliner: $ grep -o string /path/to/file | wc -l $ cat jedi jedi

Tagged with: , , , ,
Posted in The Linux and Unix Articles!

3 Usefull Oneliners #2 : find IP address, copy trick, run previous command with different arguments

1. awk trick: Find out a network interface’s IP address: This command displays only the ip of the eth0 interface. ip a s eth0 | grep “inet ” | head -n 1 | awk ‘{print $2}’ | cut -f1 -d’/’

Tagged with: , , , , ,
Posted in The Linux and Unix Articles!

20 Find oneliners for changing file and folder permissions

In this article I will show you 10 find oneliners, for manipulating the file and folder permissions. 1. Add execution rights for the user to all the files in the current directory: find . -type f -exec chmod u+x {}

Tagged with: , , , , , , , ,
Posted in The Linux and Unix Articles!

How to replace one string with another in a file

In this short article I will show you how to replace a string with another, globally, everywhere it is found. I needed this to replace one extension with another: $ rename ‘-s/\.JPG$/.jpg/’ * This little oneliner looks in all the

Tagged with: , , , , ,
Posted in The Linux and Unix Articles!
Support LinuxG via Patreon
Support LinuxG.net on Patreon!
Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!