Skip to content

Notes for 103.3 and nice to know

Notes for 103.3 and nice to know published on No Comments on Notes for 103.3 and nice to know

Change time stamp of a file:
touch -t YYYYMMDDhhmm.ss myfile
 
show full time stamp
ls -la --time-style=full-iso myfile

wildcards

? = replace one char
* = replace 0 or x chars
[a-z] = replace one char in the specified range
[abcde] = replace one char of the specified characters
[!a-z] = replace one char NOT in the specified range

tar

Not well known options
t = list
tar tzf salami.tar.gz

zipping the shit out of the files

gzip -c myfile.txt > myfile.txt.gz creates a myfile.txt.gz and does not delete the original myfile.txt
gzip -l myfile.gz lists the content of myfile.gz

decompress with:

  • gzip -d
  • gunzip
  • zcat

bzip2 has usually better compress rate. It uses the same parameters.
decompress with:

  • bzip2 -d
  • bunzip
  • bzcat

cpio

extract files out of archives
cpio -i | --extract = copy in mode; copy from archive in file system
cpio -o | --create = copy out mode; copy files into the archive
cpio -p | --pass-throughno archive, all files of stdin into a dir

backup all ods in home to backup
find /home/ -name *.ods | cpio -pd /backup

-d = creates directories

dd

backup mbr
dd if=/dev/sda of=mbr.backup ibs=512 count=1

file myfile.sh shows the type of the file

Notes for 103.2

Notes for 103.2 published on No Comments on Notes for 103.2

expand x.txt > y.txt replace TAB by spaces
nl x.txt cat with line number
uniq x.txt remove duplicates
split -l 11000 -d catalina.out salami_ split catalina.out evere 11000 lines to a file salami_nn (-d is for numeric file number)
cut -f2 tabulator.txt cut columns 2
paste x.txt y.txt merge two files by column
join -j like paste with "sql like" join on a common key
cat x.txt | tr Q P replace Q by P in x.txt
cat x.txt | tr a-z A-Z lower case to upper case
[:lower:] possible as an argument of tr