cd - # move back to the previous directory
cd ~ # move into your home directory
cd .. # move up one directory
#! /usr/bin/python
import requests
import lxml
from lxml import html
r = requests.get('https://www.google.com/')
tree = lxml.html.fromstring(r.content)
elements = tree.get_element_by_id("prm")
for el in elements:
print el.text_content()
LOAD DATA INFILE 'myfile' INTO TABLE table FIELDS TERMINATED BY ',';
cat command functionality:
1. create
2. view
3. join files
cat is short for catenate (to join things together, end-to-end)
- Create file
cat > file1
enter text
more text
# press Enter, CTRL-d to exit
- View file(s)
cat -n filename # will number all lines
cat -b filename # will number all non-blank lines
cat -t filename # all tabs to be shown as ^I
cat -s filename # remove extra blank lines. 1 blank line is allowed.
cat -A filename # combine -t & -s options together
- Join Files
cat test1 test2 # join both files and show output in stdout
cat test1 test2 > test # Join both files and add to stdout
GNU Readline Library enable to edit the command line shortcuts. Readline uses emacs key binding. It means a lot of CTRL/ALT keys.
- Ctrl+C # Interrupt to exit, terminate the command
- Ctrl+D # disconnect from shell
- Ctrl+Z # suspend the process, suspend/stop the command
- Ctrl+l # clear screen
- Ctrl+s # stops the output to the screen
- Ctrl+q # allow output to the screen
(If previously stopped using Ctrl+s)- !! - run last command
- Ctrl+r # search the history backwards
- Ctrl+g # escape from history searching mode
- Ctrl+a # go to start of the command line
- Ctrl+e # go to end of the command line
- Ctrl+f # move forward one character (identical to VIM)
- Ctrl+b # move backward one character (identical to VIM)
- Ctrl+p # previous command in history
- Ctrl+n # next command in history
diff from_file to_file
diff from_dir to_dir
diff useful lags
-B (Ignore changes whose lines are all blank.)
-b (Ignore changes in the amount of white space)
-y (side by side ouput comparison)
useful alias:
diff -Bb alias
Ways to change Linux shell
1. chsh (change login shell)
2. edit /etc/password
3. exec in .login file