cmdref.net - Command Reference

This site is command references for system engineers.

User Tools

Site Tools


Top     OS ( Linux )     Middleware     Protocol     Hardware     Programming ( Shell Script )     SiteMap

Sidebar

Top     SiteMap








Reference











.

os:linux:note:bash.thml



Linux

Bash - How to Use and Configure Bash in Linux

man bash

$ man bash

   Commands for Moving
       beginning-of-line (C-a)
              Move to the start of the current line.


Check bash Options

$ echo $SHELLOPTS
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor


Bash Operation

emacs mode (default)

set -o emacs

Commands for Moving

Operation Commands appendex
Move to the start of the current line. Ctrl + a Ahead
Move to the end of the line. Ctrl + e End
Move back a character. Esc - b Back
Move forward to the end of the next word. Esc - f Forward

Killing and Yanking

Operation Commands appendex
Kill the word behind point, using white space as a word boundary. Ctrl + w
Kill the text from point to the end of the line. Ctrl + k
Kill backward from point to the beginning of the line. Ctrl + u

Window

Operation Commands appendex
Clear the screen leaving the current line at the top of the screen. Ctrl + l
Ctrl + c
Ctrl + s
Ctrl + q

History

Operation Commands appendex
Fetch the previous command from the history list, moving back in the list. Ctrl + p
Fetch the next command from the history list, moving forward in the list. Ctrl + n
Search backward starting at the current line and moving `up' through the history as necessary. Ctrl + r 'Esc' is cansel this operation.


vi mode

set -o vi


Brace expansion {}

$ echo 192.168.0.{100,101}
192.168.0.100 192.168.0.101
$ echo 192.168.0.{100..102}
192.168.0.100 192.168.0.101 192.168.0.102
$ H=`echo 192.168.10.{1..15}`
$ for i in $H ; do echo $i ; done
$ for i in $H ; do host $i ; done
$ cp hoge.txt{,.org}      <- copy and .org

$ mv filename{,.org}      <- add .org
$ mv filename{.org,}      <- delete .org


$ mkdir {dir1,dir2,dir3}
$ ls
dir1/  dir2/  dir3/


$ mkdir dir{1,2,3}
$ ls
dir1/  dir2/  dir3/


$ cp  images/{foo,bar}*.gif  ~/


$ cp  {foo,bar}.jar  ~/
$ for i in `ls -1` ; do echo $i ; done
$ for i in `ls -1` ; do cp $i{,.new} ; done
## From *.org To .new
$ for i in *.org; do cp $i ${i%.org}.new ; done
$ date;for i in 192.168.0.{10,11} 192.168.1.{1..5} ; do ssh $i "uname -n;/sbin/ifconfig | grep add" ; echo  ; done



os/linux/note/bash.thml.txt ยท Last modified: 2017/05/14 by admin