…One of the primary reasons you might want to write a script rather than…execute commands line by line is to…incorporate some logic into what you're doing.…For this, comparisons can be very useful.…We do this with double square brackets, a notation borrowed from KornShell.…It's important to keep spaces between the sets of brackets and the expression.…This expression returns 1 or 0 for failure or success.…Bash supports the standard compliment of comparators.…Less than, greater than, less than or equal to,…greater than or equal to, equal, and not equal.…These work within the double square brackets to compare strings.…
Let's take a look at how these work.…I'll test to see if one string is equal…to another and then echo the return value with $?…In this test context, you can use a single…or a double equals sign to test for equality.…I'll save that and then I'll run it.…And you see the first test for cat equals cat returns 0 for success.…And the next one cat equals dog returns 1 or failure.…I'll jump back into my script and I'll add another test.…
- What is Bash?
- Managing output with grep, awk, and cut
- Understanding Bash script syntax
- Creating a basic Bash script
- Displaying text with "echo"
- Working with numbers, strings, and arrays
- Reading and writing text files
- Working with loops
- Using functions
- Getting user input during execution
- Ensuring a response
Skill Level Beginner
Linux: Bash Shell and Scriptswith Kevin Dankwardt2h 46m Intermediate
1. Working with the Command Line
2. Building Bash Scripts
3. Control Structures
4. Interacting with the User
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.