Tips & Tricks

@@Shell_logo@@

Shell

Modules / libraries

Tricks

Remove files with names that contains special characters

mv -- --remove-files remove-files

Difference between the content of two files

@@Stackoverflow_com_logo@@ Stackoverflow: Difference between the content of two files

1 Only one instance , in either

cat File1 File2 | sort | uniq -u

2 Only in first file

cat File1 File2 File2 | sort | uniq -u

3 Only in second file

cat File1 File1 File2 | sort | uniq -u

Record handling

Archive and delete files

# Find file older than 90 sec and tar
find . -type f -mtime +90 -name 'emailntc.ran.*' | xargs tar cvf emailntc.ran.tar 
# Delete archived files
find . -type f -mtime +90 -name 'emailntc.ran.*' | xargs rm

Get doxy header

# Print header
grep -E '^#\s+@' $0 1>&2

Zulu time

date -u +%Y-%m-%dT%H:%M:%S%z

crontab guru

The quick and simple editor for cron schedule expressions by Cronitor: https://crontab.guru/#/10_7-17_**

Archive and remove old files

# List old files
find ./ -maxdepth 1 -type f -mtime +365 -print >remove
# Archive old files
tar -cvf remove.2023-07-20.tar -T remove
# Remove
xargs rm < remove

External