mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-13 23:49:31 +01:00
63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
|
1. for f in $(ls *.mp3)
|
||
|
2. cp $file $target
|
||
|
3. Filenames with leading dashes
|
||
|
4. [ $foo = "bar" ]
|
||
|
5. cd $(dirname "$f")
|
||
|
6. [ "$foo" = bar && "$bar" = foo ]
|
||
|
7. [[ $foo > 7 ]]
|
||
|
8. grep foo bar | while read -r; do ((count++)); done
|
||
|
9. if [grep foo myfile]
|
||
|
10. if [bar="$foo"]; then ...
|
||
|
11. if [ [ a = b ] && [ c = d ] ]; then ...
|
||
|
12. read $foo
|
||
|
13. cat file | sed s/foo/bar/ > file
|
||
|
14. echo $foo
|
||
|
15. $foo=bar
|
||
|
16. foo = bar
|
||
|
17. echo <<EOF
|
||
|
18. su -c 'some command'
|
||
|
19. cd /foo; bar
|
||
|
20. [ bar == "$foo" ]
|
||
|
21. for i in {1..10}; do ./something &; done
|
||
|
22. cmd1 && cmd2 || cmd3
|
||
|
23. echo "Hello World!"
|
||
|
24. for arg in $*
|
||
|
25. function foo()
|
||
|
26. echo "~"
|
||
|
27. local var=$(cmd)
|
||
|
28. export foo=~/bar
|
||
|
29. sed 's/$foo/good bye/'
|
||
|
30. tr [A-Z] [a-z]
|
||
|
31. ps ax | grep gedit
|
||
|
32. printf "$foo"
|
||
|
33. for i in {1..$n}
|
||
|
34. if [[ $foo = $bar ]] (depending on intent)
|
||
|
35. if [[ $foo =~ 'some RE' ]]
|
||
|
36. [ -n $foo ] or [ -z $foo ]
|
||
|
37. [[ -e "$broken_symlink" ]] returns 1 even though $broken_symlink exists
|
||
|
38. ed file <<<"g/d\{0,3\}/s//e/g" fails
|
||
|
39. expr sub-string fails for "match"
|
||
|
40. On UTF-8 and Byte-Order Marks (BOM)
|
||
|
41. content=$(<file)
|
||
|
42. for file in ./* ; do if [[ $file != *.* ]]
|
||
|
43. somecmd 2>&1 >>logfile
|
||
|
44. cmd; (( ! $? )) || die
|
||
|
45. y=$(( array[$x] ))
|
||
|
46. read num; echo $((num+1))
|
||
|
47. IFS=, read -ra fields <<< "$csv_line"
|
||
|
48. export CDPATH=.:~/myProject
|
||
|
49. OIFS="$IFS"; ...; IFS="$OIFS"
|
||
|
50. hosts=( $(aws ...) )
|
||
|
51. Non-atomic writes with xargs -P
|
||
|
52. find . -exec sh -c 'echo {}' \;
|
||
|
53. sudo mycmd > /myfile
|
||
|
54. sudo ls /foo/*
|
||
|
55. myprogram 2>&-
|
||
|
56. Using xargs without -0
|
||
|
57. unset a[0]
|
||
|
58. month=$(date +%m); day=$(date +%d)
|
||
|
59. i=$(( 10#$i ))
|
||
|
60. set -euo pipefail
|
||
|
61. [[ -v hash[$key] ]]
|
||
|
62. (( hash[$key]++ ))
|