Differences between revisions 4 and 5
Revision 4 as of 2011-04-13 07:13:09
Size: 1296
Editor: SamatJain
Comment: Add ToC
Revision 5 as of 2014-12-04 06:02:21
Size: 1503
Editor: SamatJain
Comment: Backup w/ tar
Deletions are marked like this. Additions are marked like this.
Line 16: Line 16:
}}}

== Backup ==

{{{#!highlight sh numbers=off
tar cvpf backup.tar \
--exclude=/proc \
--exclude=/lost+found \
--exclude=/backup.tar \
--exclude=/mnt \
--exclude=/sys \
--exclude=/dev/pts \
/

Set operations on lines of a file

# Union of unsorted files, items in either file1 or file2
sort file1 file2 | uniq
# Intersection of unsorted files, items in both file1 and file2
sort file1 file2 | uniq -d
# Difference of unsorted files, items in file2 not in file1
sort file1 file1 file2 | uniq -u
# Symmetric Difference of unsorted files, items in file1 or file2 but not both
sort file1 file2 | uniq -u

Backup

tar cvpf backup.tar \
--exclude=/proc \
--exclude=/lost+found \
--exclude=/backup.tar \
--exclude=/mnt \
--exclude=/sys \
--exclude=/dev/pts \
/

Unit conversion

units -t '100m/9.58s' 'miles/hour'
units -t '500GB' 'GiB'
units -t '1 googol'

Dates

What time is it elsewhere?

TZ='America/Los_Angeles' date
TZ='America/Denver' date
TZ='America/New_York' date
TZ='UTC' date

Check /usr/share/zoneinfo/ to find values for $TZ.

Convert UNIX epoch seconds to date

date --date='@2147483647'

Exit a script unless it's the last day of the month

[ $(date -d "tomorrow" +%d) = "01" ] || exit

Calendar for particular month and year

cal 9 1752


CategoryCheatSheet

SamatsWiki: CheatSheet/GNUCoreUtils (last edited 2015-01-15 21:58:34 by SamatJain)