Tools in the posix and nushell command line
<|
Back to index
grep find one of two patterns
grep -e pattern1 -e pattern2
split and reunite large files
#split in 3GiB sized files and then reunite
split -b 3G file_to_split.iso file_to_split.iso
cat file_to_split.iso* > file_to_split.iso
python compute days
>>> from datetime import date
>>> a=date(2021,8,26)
>>> b=date(2021,9,15)
>>> c=date(2021,11,15)
>>> d=date(2022,3,3)
>>> (a-b).days
-20
>>> (b-a).days
20
>>> (d-c).days
108
>>> 20+108
128
>>> #compute final date that is 119 days later
>>> from datetime import date, timedelta
>>> end_date=date.today()+timedelta(days=119)
nushell compute days
("28-sep-2024" | into daytime) + (119day)
(date now) + (2day)
beep timer in nushell and posix command line
(
date now | print;
printf "TIMER_MESSAGE\n";
(date now) + (30min) | print;
sleep 30min;
printf "BEEPING\n";
for $it in 0..999999 {
sleep 1sec; printf "\a"
}
)
printf "\a"
#if the command 'printf "\a"' above does not generate a sound
#'gnome-terminal --sh -c 'printf "\a"''
#above sidesteps that buggy situation
grep recursive full text search
grep -rnw folder -e 'PATTERN'
list files by size recursively
du -ah . | grep -v "/$" | sort -rh | less
sed replace text in file
sed -i -- 's/foo/bar/g' file_path
grep find files with extension sh
find * | grep -i '\.sh$'
sed comment lines in shell script
sed -i '2,4 s/^/#/' file_path
apt exact search
apt search ^golang$
invert grep search
ls -alh | grep -v regex_to_exclude
Open websites with xargs and xdg-open
printf "https://www.web1.com\nhttps://www.web2.com\n" \
| xargs -I website xdg-open website
git good looking log command options
git log -2 --oneline --decorate --graph --all
git wipe latest commit
#!!! - WARNING - VERY DANGEROUS COMMAND
#!!! - BY RUNNING IT YOU MAY LOOSE IMPORTANT DATA
#!!! - KNOW WHAT YOU ARE DOING BEFORE RUNNING THIS COMMAND
git reset --hard HEAD~1