linux:bashshell
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:bashshell [2016/01/15 04:43] – [bash function] admin | linux:bashshell [2017/01/12 02:12] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
Bash script: http:// | Bash script: http:// | ||
====== Linux Bash Shell Script ====== | ====== Linux Bash Shell Script ====== | ||
- | ===== create simple | + | ===== Simple |
* create helloworld.sh< | * create helloworld.sh< | ||
cat > helloworld.sh | cat > helloworld.sh | ||
Line 87: | Line 87: | ||
</ | </ | ||
- | === variable | + | === Variable |
* create script test.sh with content below:< | * create script test.sh with content below:< | ||
#!/bin/bash | #!/bin/bash | ||
Line 163: | Line 163: | ||
==== Bitwise operators ==== | ==== Bitwise operators ==== | ||
==== comparision operators ==== | ==== comparision operators ==== | ||
- | === integer | + | === Integer |
-eq : is equal to<code bash> | -eq : is equal to<code bash> | ||
if [ " | if [ " | ||
Line 194: | Line 194: | ||
((" | ((" | ||
</ | </ | ||
- | === string | + | === String |
String Comparisions: | String Comparisions: | ||
* =: is equal to<code bash> | * =: is equal to<code bash> | ||
Line 236: | Line 236: | ||
echo $date | echo $date | ||
</ | </ | ||
- | ==== loop with while ==== | + | ==== Loop with while ==== |
loop with while:< | loop with while:< | ||
<code bash> | <code bash> | ||
Line 246: | Line 246: | ||
done < /tmp/a1.txt | done < /tmp/a1.txt | ||
</ | </ | ||
- | ==== array ==== | + | ==== Array ==== |
* Init the array and access the elements of array:< | * Init the array and access the elements of array:< | ||
arr=( zero one two three four five ) | arr=( zero one two three four five ) | ||
Line 316: | Line 316: | ||
==== Find files that contain the text ==== | ==== Find files that contain the text ==== | ||
<code bash> | <code bash> | ||
- | grep -rnw babyshopvn | + | grep -rnw . -e "Begin Facebook Code" |
+ | </ | ||
+ | ==== Manipulating String ==== | ||
+ | refer: http:// | ||
+ | * String length: **${# | ||
+ | str=" | ||
+ | </ | ||
+ | 12 | ||
+ | </ | ||
+ | * Replace String:< | ||
+ | str=" | ||
+ | </ | ||
+ | Second String | ||
+ | </ | ||
+ | ==== update array to file ==== | ||
+ | Below is array configs.txt:< | ||
+ | c1 = 0, | ||
+ | c2 = 51, | ||
+ | c3 = 26, | ||
+ | </ | ||
+ | update array to files: | ||
+ | <code bash> | ||
+ | index=0;for i in `cat configs.txt | awk ' | ||
</ | </ |
linux/bashshell.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1