Count the number of ‘|’ in a file per line.
sed 's/[^|]//g' test.csv | awk '{ print length }'
Print the lines with line number which do not contain ’67’
grep -n -v 67 number_of_pipes.txt
Print line 929064 of file ‘test.txt’
sed '929064q;d' test.txt
Open file ‘test.txt’ in line 929064 with vi
vi +929064 test.txt
The first day of the month two months ago in SQL
select add_months(from_unixtime(unix_timestamp(),'yyyy-MM-01'),-2)
Subtract a month and reformat date:
select from_unixtime(unix_timestamp(add_months(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),-1),'yyyy-MM-dd'),'yyyyMMdd');
Remove DOS linefeeds:
awk 'sub("\r$", "")' myfile > tmp ; mv tmp myfile
from this page.
Rsync files to a Windows shared drive in WSL:
Login as root
and run
mount -t drvfs '\\servername\folder\the share' /mnt/the_share
to mount the shared drive and then run rsync
rsync -avz --delete /my/directory/ /mnt/the_share --partial --progress --modify-window=2 --bwlimit=100
. The avz
option only works as root
in the setup I’m using. The bandwidth limitation ensures the home home broadband is not maxed out.