DEV Community

moogoo
moogoo

Posted on • Updated on

Useful command-line snippets

move to https://app.heptabase.com/w/3c34815462d03f458145e38c717b14fa2bd49792af07deb2f0127f6247111801?id=74470eaa-83da-461e-ad44-545255f89e03 (2023-05-23)

Files & Directory

count number of files

$ find [PATH] -type f | wc -l
Enter fullscreen mode Exit fullscreen mode

delete thumb files

find . -name ".DS_Store" -delete
find . -type f -name '._*' -delete
find . -type f -not -name '._*' -size -5k
Enter fullscreen mode Exit fullscreen mode

other

find . -size -5k -type f
Enter fullscreen mode Exit fullscreen mode

find number of files in each folder

du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
Enter fullscreen mode Exit fullscreen mode

via https://stackoverflow.com/a/39622947/644070

batch process

replace character

replace line-break (\n) to ,

tr '\n' ',' < source-file
Enter fullscreen mode Exit fullscreen mode

delete character

tr -d `\n` < source-file
Enter fullscreen mode Exit fullscreen mode

mix and combination

conver mp3

find *.wav -exec ffmpeg -i {} {}.mp3 \;
Enter fullscreen mode Exit fullscreen mode

Dist utilities

test HD Performance

Use the dd command to measure server throughput (write speed):

dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
Enter fullscreen mode Exit fullscreen mode

Linux and Unix Test Disk I/O Performance With dd Command - nixCraft

Top comments (0)