grep -e word1 -e word2 file
or
grep "word1\|word2" file
or
grep -E "word1|word2" file
pip3 list -o
or
pip2 list --outdated
cat file.txt | awk '{print $2}'
stdout
and stderr
to the
same file while running something in the background:
ls -lR > output 2>&1 &
. Note that if you
start a process running in the background on ssh and
then abruptly terminate the session without explicitly
typing 'exit', then the background job will be
terminated. In order to ensure a network disconnect does
not terminate your job, exit the ssh session after
beginning the background job and start a new ssh session
to monitor the output. See also
the Redirections
section of the bash manual.du -a directory_name | sort -n -r
du -s directory
chmod -R u+rwX,go+rX,go-w /path/to/dir
find . -name "*.txt"
paste 1.txt
2.txt | more
This is particularly
useful for comparing the output of two versions
of a code.wget http://host.com/dir/file.html
or
curl http://host.com/dir/file.html
head -n 10 file.txt
,
tail -n 10 file.txt
. Or to watch
("follow") a text file as it is being created:
tail -f file.txt
.
brew leaves | xargs brew deps --installed --for-each | sed "s/^.*:/$(tput setaf 4)&$(tput sgr0)/"
montage image1.jpg image2.jpg image3.jpg
image4.jpg -geometry +2+2 output.jpg
ps ux
,
and owned by everyone ps aux
.Here is a list of UNIX commands and concepts which I recommend everyone know:
ls
to list the files in
a directory, and how to use ls -a
and ls
-l
cat
and more
(or less
) to view
a filecd
to change directory and what
cd .
and cd ~
mean.
cp
to copy a file,
mv
to move (or rename) a file, and rm
to delete a file. What the -i
flag means for
these commands.
ssh
to connect securely to
different computers and scp
to transfer
files securely. When you starting out (or if you are
having problems), you should try
ssh -v
so that you see what SSH is doing.
grep
to search in filesman <command>
and <command> --help
to learn more
about a command.top
to examine currently
running processes and how to use kill
to stop a processBack to Andrew W. Steiner at the University of Tennessee.