DEV Community

Romero Dias
Romero Dias

Posted on • Updated on

Linux Useful Commands

Find duplicate entries in text file
sort file.txt | uniq -d

Grep showing the line number
grep -in 'text to find' file.txt

Get file lines
wc -l file.txt

Show only file name
ls -1 *.*

Find and delete files
find . -type f -name "*.ico" -exec rm {} \;

Find and rename files with sed

find <search-path> -type f -name "*.txt*" | while read FILENAME ; do 
      NEW_FILENAME="$(echo ${FILENAME} | sed -e "s/<search>/<replace>/g")";
      mv "${FILENAME}" "${NEW_FILENAME}";
  done
Enter fullscreen mode Exit fullscreen mode

Top comments (0)