Join Scott Simpson for an in-depth discussion in this video Working with strings, part of Up and Running with Bash Scripting.
- View Offline
- Exercise Files
…Bash provides for string manipulations…like concatenation, substring extraction, and replacement.…Probably the simplest string manipulation you'll use…it concatenation, sticking one string onto another.…And it's really straight forward.…For this movie, I'll just use the command line instead of a script file.…I'll set a equals to hello and b equal to world.…And then to create a string out of…both of these put together or concatenated together,…I'll define the variable c equal to a and b, just right next to each other.…And if I echo that, you can see I have my concatenated string.…You can find out how long a string is using…a pound or hash sign in front of the variable name.…
Here I'm using parameter expansion.…And you can see when I run that, I get the length…of each of those strings, a and c, 5 and 10 characters respectively.…You can also ask to just have a…certain piece or a substring from an existing string.…And for that, you'll use a colon followed by an index number to start from.…Keep in mind that the first character is at index 0.…
- 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
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.