Skip to content

Instantly share code, notes, and snippets.

@RamiKrispin
Last active September 9, 2019 15:30
Show Gist options
  • Save RamiKrispin/c61dc3fb7cc01e8985a2de5e129cab69 to your computer and use it in GitHub Desktop.
Save RamiKrispin/c61dc3fb7cc01e8985a2de5e129cab69 to your computer and use it in GitHub Desktop.
Terminal common commands

Notes about command lines functions from the "Data Science at the Command Line"

echo is a command that outputs the strings it is being passed as arguments

echo 'Hello World'
Hello World

wc - word count

echo 'Hello World' | wc
 1       2      12

alias set an alias

alias gp = 'git push origin master'

grep used for regular expression

seq 30 | grep 3
3
13
23
30

Or

seq 30 | grep 3 | wc -l
4

Creating a new file using > operator Append for existing fill using the >> operator

echo -n "Hello" > hello-world.txt
echo " World" >> hello-world.txt

cat print the conent of a file

cat hello-world.txt | wc -w 

Move a file for a different directory with the mv command

mv hello-world.txt ~/Downloads

cp command for copy a file

The man provides the command documentation

man cat

To show only the first 20 lines:

man cat | head -n 20

Similarly, the help command returns the help documentation of the command (not always the man is available)

help cd | head -n 20
@RamiKrispin
Copy link
Author

init commit

@RamiKrispin
Copy link
Author

Update the gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment