Notes
  • Notes
  • JavaScript
    • URL processing
    • Numbers
  • Python
    • python random notes
    • Python Resources
  • Setup
    • Mac Setup
  • Command Line
    • Basics
    • Linux basics
    • Bash script
    • Create temp files
    • awk
    • sed
    • make
    • ssh
    • gzip
    • Command line tools
    • ffmpeg
    • at and crontab - scheduling commands
  • Web Developement
    • Chrome Dev Tools
    • HTML
    • Markdown
    • CSS
    • Rails
    • Hugo
    • REST APIs
  • Soft Skills
    • Listening Skills
    • Public Speaking
  • Containers
  • Career
    • Resume
    • Interview
    • Promotion
    • Keeping Track of Your Work
    • Decide What to Work On
  • Ergonomics
    • Work Env Setup
    • Pain Relieve
  • Digest / Writing Ideas
    • Books
      • Antifragile
      • Anti-Intellectualism in American Life 美国的反智传统
    • Economy / Society
    • How to spend your time
    • Life
    • Higher education
  • Misc
    • Regex
    • Don't Make Me Think
    • Microsoft Excel
    • AdTech 101
  • Resources
    • web
    • Vim
    • Tools
    • System Design
    • Design Pattern
    • Load Balancer
    • References
    • Hardware
    • Algorithm Resources
    • Command Line Resources
  • Git
    • Pro Git
  • Non-Tech
    • 化学科普 - 拿破仑的纽扣
    • 人生经验 - If I Knew Then
    • 哲学
      • Harvard - Justice
    • 宗教
      • Introduction to the New Testament History and Literature
      • 蔡志忠 - 漫画东方圣经
    • 人文
      • Open Yale Course - 心理学导论
  • Spark
  • VS Code
Powered by GitBook
On this page
  • Command Line Article List (Under Construction)
  • Regex
  • cd
  • ls
  • If the number of argument is less than 1, exit with a usage statement.

Was this helpful?

  1. Resources

Command Line Resources

PreviousAlgorithm ResourcesNextGit

Last updated 5 years ago

Was this helpful?

Command Line Article List (Under Construction)

cat is short for concatenate.

Shell 脚本学习指南

; is to separate commands in the same line & run the first command in background. Continue following commands (don’t wait the completion) Options with no arguments can be combined -l -t abc.c => -lt abc.c Echo \f 清屏

Command < file ( < change stdin)

will create the file if not exist. If exist, will override

Pipe: faster x10 than temp file Use the command that would decrease the data first

不关心命令输出,只关心命令退出状态:> /dev/null

read password < /dev/tty 从终端读入密码 stty-echo / echo 关闭/打开 自动打印输入字符 PATH: 用:分开的一系列目录 用于查找命令 永久修改:加入bashrc PATH=$PATH:$HOME/bin

命令行参数 $1 ${10}

Who 显示所有用户

chapter2 Cc File.c | grep -v ^$ > file.c 删除空行并储存 -i 忽略大小写 -r 查找所有文件 -n 显示行数 -C5 显示上下文 5行

Regex

替换 sed

Cut

cd

$ cd / # to the root $ cd ~ # to /User/davidfeng (home directory)

ls

ls -R show all files in the subfolders. ls -lah [name of file] # see the permissions

whoami # show the current user

chmod +rw # change mode: add/subtract permissions $ chmod u+x hello_world.sh # u is user (myself)

$ which grep # where the command grep is installed? $ history # shows history of commands

move to the front/end of a command: ctrl +a/e

bat is a better version of cat ack is a better version of grep

Learn Enough command line $ echo 1 > afile create a file named “afile” with content 1. If afile already exist, it overrides the content. echo 2 >> afile (append 2)

random source ~/.bashrc source can be replaced with a . => . ~/.bashrc

wc filename word count

kill a process kill -options id kill -15 12345 -15: gental kill. Give the process a chance to clean up temp files other options: 2, 1, 9

make a new bash command “ekill”: Listing 21: A custom escalating kill script. ~/bin/ekill 1 #!/bin/bash 2 3 # Kill a process as safely as possible. 4 # Tries to kill a process using a series of signals with escalating urgency. 5 # usage: ekill 6

If the number of argument is less than 1, exit with a usage statement.

if [[ $# -lt 1 ]]; then echo "usage: ekill " exit 1 fi 7 # Assign the process id to the first argument. 8 pid=$1 9 kill -15 $pid || kill -2 $pid || kill -1 $pid || kill -9 $pid

To make ekill work: ~/bin is on the system path. echo $PATH if /Users/davidfeng/bin is not listed, edit bashrc export PATH="~/bin:$PATH" # sometimes $HOME works instead of ~ make the script itself executable chmod +x ~/bin/ekill confirm: which ekill => gives the full path to the script

ps aux: show all processes tail: get a hanging process

curl -0L url/filename #download unzip xyz.zip

grep -n Waldo * #-n for line number use grep in vim: -n is added automatically. -i: ignore case.

awesome command line

The linux command line中文版书

The Unix Chainsaw - Gary Bernhardt

IBM - Introduction to text manipulation on UNIX-based systems

PDF

Unix text process

example

{n} {n,} {n,m} ^ 在方括号内表示取反

A better Mac Terminal experience

终端使用技巧

=> Unix shell fundamentals 9h command line programs including ls vi grep etc.

Shell十三问 Linux C编程

learn enough command line Ten things I wish I knew about bash shellcheck safe way to do things in bash

CLI improved 中文

find .git/objects # find subfolders find .git/objects -type f # only find files, exclude directories yes command: can take optional argument, output confirm messages until killed. man: manual space bar: turn to next page in a long doc. (man, cat, etc) q: quit ^: ctrl ^A: move to beginning of a line ^E: move to end of line ^U: clear the line from cursor to beginning option + left click: move the cursor move forward/backward by one word: mac terminal: option + left/right; iTerm2: esc + b/f

https://www.kawabangga.com/posts/4012
https://billie66.gitbooks.io/tlcl-cn/content/chap00/introduction.html
https://www.youtube.com/watch?v=sCZJblyT_XM
https://www.ibm.com/developerworks/aix/library/au-unixtext/index.html
https://www.ibm.com/developerworks/aix/library/au-unixtext/au-unixtext-pdf.pdf
https://en.m.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_Unix_Command_Line
http://vegardstikbakke.com/unix/
https://www.oreilly.com/openbook/utp/
https://news.ycombinator.com/item?id=19160659
https://regex101.com/
https://medium.com/@caulfieldOwen/youre-missing-out-on-a-better-mac-terminal-experience-d73647abf6d7
https://www.kawabangga.com/posts/2432
https://www.safaribooksonline.com/library/view/unix-shell-fundamentals/1930519915/c0000.html
http://bbs.chinaunix.net/thread-218853-1-1.html
https://akaedu.github.io/book/index.html
https://www.learnenough.com/command-line-tutorial#sec-exercises_editing_the_line
https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/
https://github.com/koalaman/shellcheck
https://github.com/anordal/shellharden/blob/master/how_to_do_things_safely_in_bash.md
https://news.ycombinator.com/item?id=17057596
https://www.kawabangga.com/posts/3084
https://remysharp.com/2018/08/23/cli-improved
https://github.com/jlevy/the-art-of-command-line#one-liners
https://henrikwarne.com/2018/08/11/my-favorite-command-line-shortcuts/
http://www.catonmat.net/blog/bash-one-liners-explained-part-one/
https://github.com/Bash-it/bash-it
https://www.learnenough.com/command-line-tutorial
SSH Examples, Tips & Tunnels
tldr in Go
the Art of Command Line
Search files in Linux
Coupled commands with control operators in Bash
Top Ten One-Liners from CommandLineFu Explained
Bash Emacs Editing Mode Cheat Sheet
Working Productively in Bash's Vi Command Line Editing Mode (with Cheat Sheet)
Helpful Terminal Commands for Beginners!
Home | Linux Journey
Bash 脚本教程
An Introduction To Data Science On The Linux Command Line
Logo
Logo
Logo