Replace spaces with commas from one file and send the output to another file.
tr -s '[:blank:]' ', ' < input.txt > output.txt |
It’s perfect for creating a comma delimited file for importing to Excel.
cloud engineer
Replace spaces with commas from one file and send the output to another file.
tr -s '[:blank:]' ', ' < input.txt > output.txt |
tr -s '[:blank:]' ', ' < input.txt > output.txt
It’s perfect for creating a comma delimited file for importing to Excel.
Here’s how to reduce a MP4 video using H.265 format.
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4 |
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4
I was able to reduce a video file from 550MB to 26MB without much quality loss.
How to sort files in Bash.
Display contents
$ cat file.txt
bbb
aaa
ccc
kkk
uuu
ppp |
$ cat file.txt bbb aaa ccc kkk uuu ppp
Sort
$ sort file.txt
aaa
bbb
ccc
kkk
ppp
uuu |
$ sort file.txt aaa bbb ccc kkk ppp uuu
Sort in place
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu |
$ sort -o file.txt file.txt $ cat file.txt aaa bbb ccc kkk ppp uuu
This will display only lines 40-50 in a file called lines.txt.
$ cat lines.txt | head -n 50 | tail -n 10 |
$ cat lines.txt | head -n 50 | tail -n 10
For lines 90-100.
$ cat lines.txt | head -n 100 | tail -n 10 |
$ cat lines.txt | head -n 100 | tail -n 10
and so on.
Here’s how to view system memory on Linux.
Default display is in kB
cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB |
cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB
Display in MB
awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB |
awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB
Output in GB
awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB |
awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB