NetWiki

I can make net work

User Tools

Site Tools


linux:start

This is an old revision of the document!


Linux

Info on that horrible operating system that's a million times better than Micro$oft Windoze. Why do I say it's horrible? Mostly because I don't spend enough time there to know how to do things and figuring it out is often a PITA.


Commifying a number in Linux

grep MemTotal /proc/meminfo | tr -s ' ' | cut -d ' ' -f 2 | xargs printf "%'d\n" 

Bonus: That particular command tells you how much memory is installed. I think.


Pad IPs to Make Them Sortable

echo 172.16.16.112/30 | awk -F '[./]' '{printf "%03d.%03d.%03d.%03d/%03d\n", $1,$2,$3,$4,$5}'
172.016.016.112/030

Date

My preferred date/time format is ISO 8601.

date '+%Y-%m-%d_%H:%M:%S'

Can also be accomplished with…

date '+%F_%T'

Specific timezone and 3 hours in the future…

TZ="America/New_York" date -d "+3 hours" '+%Y-%m-%d_%H:%M:%S'

Find

I never remember how to find old files… either of these will work. The second one uses minutes (I don't know why you'd want to) and shows how to exclude files.

find DIR -name "*_FILENAME-*.gz" -mtime +45
find . ! -name '*NOT_THIS*.gz' -mmin +$((45*24*60))

Add this to the end and anything that matches will be deleted.

-exec rm -f {} \;

Limit depth to current directory.

find . -maxdepth 1 -name "v*.tar.gz" -mtime +30

———————–

linux/start.1695673990.txt.gz · Last modified: 2023-09-25 20:33 by dave

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki