9 Leveraging Text Files
9. Leveraging Text Files # Prints all usernames (the first field) alphabetically $ cut -d: -f1 /etc/passwd | sort avahi backup daemon ⋮ $ awk -F: '$3>=1000 {print $1}' /etc/passwd \ | xargs ...
9. Leveraging Text Files # Prints all usernames (the first field) alphabetically $ cut -d: -f1 /etc/passwd | sort avahi backup daemon ⋮ $ awk -F: '$3>=1000 {print $1}' /etc/passwd \ | xargs ...
8. Building a Brash One-Liner Get Ready to Be Brash Be Flexible $ echo $(ls *.jpg) $ bash -c 'ls *.jpg' $ cat <(ls *.jpg) $ find . -maxdepth 1 -type f -name \*.jpg -print $ ls > tmp &&a...
7. More Ways to Run a Command List Techniques Technique #1: Conditional Lists $ cd dir Enter the directory $ touch new.txt Make the file $ cd dir && touch new.txt $ cp...
6. Parents, Children, And Environments Shell Are Executable Files $ cd /bin $ ls -l bash cat ls grep -rwxr-xr-x 1 root root 1113504 Jun 6 2019 bash -rwxr-xr-x 1 root root 35064 Jan 18 2018 c...
5. Expanding Your Toolbox Producing Text $ cut -d: -f1 /etc/passwd | sort Print all usernames and sort them $ cat *.txt | wc -l Total the number of lines The date Comman...
4. Cruising The Filesystem Visiting Specific Directories Efficiently Jump to Your Home Directory $ pwd /etc Start somewhere else $ cd Ru...
3. Rerunning Commands All the advice in this book will serve you better if you can type quickly. No matter how knowledgeable you are, if you type 40 words per minute and your equally knowledgea...
2. Introducing The Shell Pattern Matching for Filenames $ grep Linux chapter* $ grep Linux chapter? $ grep Linux chapter?? $ grep Linux chapter[12345] $ grep Linux chapter[1-5] $ grep Linux ...
1. Combining Commands BookSite Six Commands to Get You Started Command 1: wc $ wc animals.txt 7 51 325 animals.txt # 7 lines, 51 words, 325 characters including invisible newline character...
Put them to $HOME directory. .bash_profile # make .bash_profile same as .bashrc if [ -f "${HOME}/.bashrc" ]; then source "${HOME}/.bashrc" fi .bashrc # A basic .bashrc file that sets the com...