bash basics
🗞Shell
bash
basic
- Unix: Standard input:
keyboard, standard output:screen - Stop with
strg + d
Pipe operator
Get list of logged in user names:
who > names.txt
sort < names.txtBetter:
who | sortNoteworthy unix commands
Basics
cd..
mkdir
top
rm
cp
mvWrite blablabla into .vimrc with echo
echo “blablabla” >> .vimrcRead files
cat test.tex : Displays the contents of test.tex
head test.tex : Display the first few lines
tail test.tex : Display last few lines
more test.tex :Find files
find \usr\ -name "sup*"
find /myfiles -type dOSX: Open a file
Opens the file with the default-programme for that file-ending.
By default it will be the app preview in which the pdf will be opened.
open file.pdfPlot
echo $PATHDescription
| Short | Long |
|---|---|
whatis cp |
man cp |
Compare files
Compare contents of file1 and file2:
diff file1 file2Does the same, but also works for binary
cmp file1 file2Redo last command
!!Get file-size
Get file size of myfile.txt in human readable form
du -h myfile.txtGet file size of current folder (all its files recursively)
du -d0 -h .Redirect
Redicrect output to somewhere else with >
Redirect information about logged in user into a file names.txt:
who > names.txtRedirect input to come from somewhere: <
sort < big_list_of_words.txtAppend to a list
>>
Links
Good homepages with tips:
Discuss on Twitter ● Improve this article: Edit on GitHub