Skip to content

Instantly share code, notes, and snippets.

@unleashtheginger
Last active August 3, 2021 20:40
Show Gist options
  • Select an option

  • Save unleashtheginger/0637d8b15cf520910999e6f8c9ea395b to your computer and use it in GitHub Desktop.

Select an option

Save unleashtheginger/0637d8b15cf520910999e6f8c9ea395b to your computer and use it in GitHub Desktop.
Notes made on a talk by Dan North
These were notes that I made while watching Power Use of UNIX by Dan North - https://www.youtube.com/watch?v=7uwW20odwEk
* UNIX is based on a really simple model
- Everything is a file
- Everything running is a process
- Every file is text or data
- Each command does one thing well
- Pipelines allow composiion
- The shell is your gateway to everythinga
* UNIX is good at three things
1. Fnding Things
2. Creating or transforming things
3. Managing Things
* Interesting Things
$$ is the current process
ls /proc/$$/fd shows the open files for your current shell
find -name .git
find -name .git -type d
zsh will let you do this:
print -l **/.git(/)
grep -n needle data/heystack
grep stands for Global Regular Expression Printer
Find all the words with all the vowels in order
less /usr/share/dict/british-english
grep '.*a.*e.*i.*o.*u'
Turn hey into straw and straw into gold:
sed 's/hey/straw/g; 's/straw/gold/g';
Create directories based on file names:
ls |cut -d. -f1|uniq
mkdir$(ls|cut -d.|-f1|uniq)
for f in *(.);do d={f%.*} echo mv $f; donea
% strips end of a variable
# strips the start of a variable
%% and ## are greedy versions
Put a /. at the end of a directory name to guarentee it exists
This will exclude tmpfs
df -h -x tmpfs
This will tell us the type of fs
df -h -x tmpfs -T
pgrep is like grep for processes
pgrep vim
3966
pgrep -fl vim
3966 vim
fuser - identify processes using files or sockets
lsof lists open files/sockets/etc - all files
rsync is made of magic.
My favourite rsync command is:
/usr/bin/rsync -azh --progress root@server1:'$(find /home/user/stuff/*.tar.gz -type f -ctime -1)' /location/
Process redirection
echo < (cat power-unix.txt)
less -f <(cat power-unix.txt)
grep document <(curl -s http://google.com)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment