Here’s a simple sed command to replace multiple spaces into a comma delimited file.
sample.txt
one two three four |
The sed command.
sed 's/ \+ /,/g' sample.txt > sample2.txt |
sample2.txt
one,two three,four |
cloud engineer
by Ulysses ·
Here’s a simple sed command to replace multiple spaces into a comma delimited file.
sample.txt
one two three four |
one two three four
The sed command.
sed 's/ \+ /,/g' sample.txt > sample2.txt |
sed 's/ \+ /,/g' sample.txt > sample2.txt
sample2.txt
one,two three,four |
one,two three,four
by Ulysses ·
Get a count of the number of files in a directory.
# using ls ls | wc -l ls -Aq | wc -l # include hidden files find . ! -name . -prune -print | grep -c / find .//. ! -name . -print | grep -c // # using tree if installed. yum install tree. apt-get install tree tree |
# using ls ls | wc -l ls -Aq | wc -l # include hidden files find . ! -name . -prune -print | grep -c / find .//. ! -name . -print | grep -c // # using tree if installed. yum install tree. apt-get install tree tree
by Ulysses ·
Find the biggest files in the current directory. Sort by from large to small. Display only the top 20. Display in human readable format.
find -type f -exec du -Sh {} + | sort -rh | head -n 20 |
find -type f -exec du -Sh {} + | sort -rh | head -n 20
by Ulysses ·
Find out which files or directories are using up disk resources.
# display the biggest files find -type f -exec du -Sh {} + | sort -rh | head -n 5 # display the biggest directories du -Sh | sort -rh | head -5 |
# display the biggest files find -type f -exec du -Sh {} + | sort -rh | head -n 5 # display the biggest directories du -Sh | sort -rh | head -5