Your SlideShare is downloading. ×
Shell quick reference
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Shell quick reference

278
views

Published on

Shell programming cheat sheet

Shell programming cheat sheet


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
278
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. SHELL PROGRAMMING LOOPINGQUICK REFERENCE GUIDE FOR for variable in file/list doSPECIAL CHARACTERS command; command separator done() execute commands in subshell{} execute commands in current shell WHILE/UNTIL# comments while/until test/condition$var variable do& execute in the background command` substitute standard out done‘ quote all characters in a string“ as ‘ but allow substitution CASE case option inREGULAR EXPRESSIONS option1) command;;. match any single character option2) command;;$ match preceding regular expression at the end of a line *) command;;^ match preceding regular expression esac at the beginning of a line (* is any non-defined option)* match zero or more occurrences of preceding expression IF[] match any character in the brackets if test/condition then (or range, i.e. 2-8) command[^ ] match any character not in brackets elif test/expression then (i.e., ^0-9 means non- command numeric character) else last regular expression encountered command(exp) remember expression for later fi reference{m,n} number of times occurring, with m REPETITION{m} indicating minimum and n xargs -n{m,} indicating maximum (see man page for more options)COMMANDSexit code VARIABLE EXPANSIONExit shell with code return code ${var} simple variable substitution ${var:=value}break level assign default value if not definedEscape from level of for or while loop ${var:+value} substitute value if var is non-nullcontinue level ${var:-value}Continue from level of for or while loop temporarily assign value if non-null ${var:?value}read issue error with value if var not set,Read input from a file otherwise substitute valuetestEvaluate an expression or conditiontrap Compiled by Michael Oliveri (www.mikeoliveri.com)Used for error handling Feel free to print a copy for yourself!