User:Neoksaal/Tutorials/BASH
Jump to navigation
Jump to search
Command line basics
pwd outputs the name of the current working directory. ls lists all files and directories in the working directory. cd switches you into the directory you specify. mkdir creates a new directory in the working directory. touch creates a new file inside the working directory. cat show you immediately what's inside the file
Helper commands to make navigation easier:
clear clears the terminal tab autocompletes the name of a file or directory ↑ and ↓ allow you to cycle through previous commands ls -a lists all contents of a directory, including hidden files and directories ls -l lists all contents in long format ls -t orders files and directories by the time they were last modified Multiple options can be used together, like ls -alt
From the command line, you can also copy, move, and remove files and directories:
cp copies files mv moves and renames files rm removes files rm -r removes directories rm -rf adding -f removes all the files without having to confirm
Redirection + other commands are powerful when combined with redirection commands:
> redirects standard output of a command to a file, overwriting previous content. >> redirects standard output of a command to a file, appending new content to old content. < redirects standard input to a command. | redirects standard output of a command to another command.
sort sorts lines of text alphabetically. uniq filters duplicate, adjacent lines of text. grep searches for a text pattern and outputs it. sed searches for a text pattern, modifies it, and outputs it.
wget
if the local computer doesn't have wget $ brew install wget
$ cd (folder you want to scrape data into) $ wget -r (url)