Posted: . At: 3:50 PM. This was 3 years ago. Post ID: 15442
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



Very useful Linux tips for 2021.


There are still some very useful tips for using Linux in 2021. Just like this.

Getting the size on the disk of a folder. The du -ack -h | tail -n 1 command will do this.

┌──[jason@192.168.1.3][~/Music]
└──╼  ╼ $ du -ack -h | tail -n 1
8.2G	total

This shows how much disk space the ~/Music folder takes up.

This interesting command will put line numbers on text, output, but only if it is not a blank line.

┌──[jason@192.168.1.3][~/Desktop]
└──╼  ╼ $ sed '/./=' root.desktop | sed '/./N; s/\n/ /'
1 [Desktop Entry]
2 Type=Link
3 Name=Root
4 Name[ca]=Arrel
5 Name[de]=Basisordner
6 Name[eo]=Radiko
7 Name[fi]=Juuri
8 Name[fr]=Dossier racine
9 Name[gl]=Raíz
10 Name[ja]=Root
11 Name[ms]=Root
12 Name[pl]=Katalog główny
13 Name[ru]=Корневой каталог
14 Name[sr]=Корен
15 Name[tr]=Kök Dizin
16 Comment=The Root Filesystem base
17 Comment[ca]=Directori arrel fitxers
18 Comment[de]=Die Basis des Wurzeldateisystems
19 Comment[eo]=La radika dosiersistemo
20 Comment[es]=El sistema de archivos root
21 Comment[fi]=Tiedostojärjestelmäpuun juuri
22 Comment[fr]=Le système de fichiers à la base
23 Comment[gl]=O sistema de ficheiros root

Reverse every line in a text file. This could be useful I guess…

┌──[jason@192.168.1.3][~/Desktop]
└──╼  ╼ $ sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//' tmp.desktop 
]yrtnE potkseD[
kniL=epyT
pmeT=emaN
.pmeT=]ac[emaN
netaD eräropmeT=]ed[emaN
japmetmuD=]oe[emaN
tesiakiailäV=]if[emaN
seriaropmeT=]rf[emaN
siaropmeT=]lg[emaN
温気=]aj[emaN
aratnemeS=]sm[emaN
arutarepmeT=]lp[emaN
soiráropmeT=]tp[emaN
голатак йыннемерВ=]ur[emaN
oнемервирП=]rs[emaN
pöÇ=]rt[emaN
selif yraropmeT=tnemmoC
slaropmet srextiF=]ac[tnemmoC
neietaD eräropmeT=]ed[tnemmoC
joreisod japmetmuD=]oe[tnemmoC

This example will print the file sizes in a directory listing in bytes and add commas to the output.

┌──[jason@192.168.1.3][~/Desktop]
└──╼  ╼ $ stat --format="%s %n" * | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' | head -n 25
1,314,524 100_0,273.jpg
1,303,195 100_0,283.jpg
1,307,745 100_0,284.jpg
1,320,254 100_0,330.jpg
1,282,582 100_0,357.jpg
133,110 1,381,036,356,449-960x540.jpg
54,602 1,381,036,356,449-960x540.webp
1,703,445 1,403,880,531,199.jpg
433,715 1,516,736,709,532.jpg
259,287 1,615,955,828,431.webm
20,791 account_activities_201,308.pdf
80,075 anti.png
549,997 Australian_Raven_by_lozzalee.jpg

This is another example, of the same trick.

┌──[jason@192.168.1.3][~/Desktop]
└──╼  ╼ $ ls -s --block-size=1 | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' | head -n -1
total 71,581,696
 1,314,816 100_0,273.jpg
 1,306,624 100_0,283.jpg
 1,310,720 100_0,284.jpg
 1,323,008 100_0,330.jpg
 1,286,144 100_0,357.jpg
  135,168 1,381,036,356,449-960x540.jpg
   57,344 1,381,036,356,449-960x540.webp
 1,703,936 1,403,880,531,199.jpg
  438,272 1,516,736,709,532.jpg
  262,144 1,615,955,828,431.webm
   24,576 account_activities_201,308.pdf
   81,920 anti.png
  552,960 Australian_Raven_by_lozzalee.jpg
   90,112 back.png
   32,768 backupsettings.conf
    4,096 bandcamp-dl-master
    4,096 Boomsrc

Remove the last line of each paragraph in a text file.

┌──[jason@192.168.1.3][~/Documents/bdoom]
└──╼  ╼ $ sed -n '/^$/{p;h;};/./{x;/./p;}' FAQ.txt 
Compatibility/Demos:
 
Q: I'm trying to play a demo, but it gets out of sync, what's wrong?
A: Read README.compatibility if you don't have already.
A: If everything failes report us which demo got out of sync and where we can
get it. Don't send it to us directly. Now hope the best that it gets fixed.
 
Linux:
 
Q: I get wrong colors when using SVGALib, can't you do your job right?
A: The SDL Library is broken, bug the SDL people about it.
 
OpenGL:
 
Q: I'm trying to get PrBoom with OpenGL working on my 3dfx Voodoo card on
Windows, but it doesn't work or is very slow.
A: Use Mesa3D (http://www.mesa3d.org) with 3dfx support.
 
Q: The sky looks wrong in OpenGL, WTF?
A: It seems like you are using Mesa3D. Try a newer version and if it's still not
fixed bug them about it.
A: Are you using Windows? Try using another glu32.dll.

Print the last 10 lines of a file (emulates “tail”).

┌──[jason@192.168.1.3][~/Documents/bdoom]
└──╼  ╼ $ sed -e :a -e '$q;N;11,$D;ba' FAQ.txt 
A: Use Mesa3D (http://www.mesa3d.org) with 3dfx support.
 
Q: The sky looks wrong in OpenGL, WTF?
A: It seems like you are using Mesa3D. Try a newer version and if it's still not
fixed bug them about it.
A: Are you using Windows? Try using another glu32.dll.
 
Q: I get a compile error saying PFNGLCOLORTABLEEXTPROC isn't defined
A: Get a newer version of your OpenGL headers/drivers. This problem occured on
nvidia cards. If you still can't get it working, the please tell us.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.