Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

hpr1884 :: Some more Bash tips

Some information about brace expansion in Bash that you might not know

<< First, < Previous, Latest >>

Host Image
Hosted by Dave Morriss on Thursday 2015-10-22 is flagged as Explicit and is released under a CC-BY-SA license.
Tags: Bash,brace expansion,seq.
Listen in ogg, spx, or mp3 format. | Comments (4)

Part of the series: Bash Scripting

This is an open series in which Hacker Public Radio Listeners can share their Bash scripting knowledge and experience with the community. General programming topics and Bash commands are explored along with some tutorials for the complete novice.

Some more Bash tips

We looked at Parameter Expansion back in HPR episode 1648 where we saw how Bash variables could be used, checked and edited. There are other sorts of expansions within Bash, and we'll look at one called "Brace Expansion" in this episode, which follows on from episode 1843 "Some Bash tips".

I have written out a moderately long set of notes about this subject and these are available here

Show Transcript

Automatically generated using whisper

whisper --model tiny --language en hpr1884.wav


Subscribe to the comments RSS feed.

Comment #1 posted on 2015-10-27T19:07:10Z by Frank

Thank you, Dave. A very nice piece of work.

I've been trying to understand regular expressions (I guess because I like puzzles). In addition to giving me a better understanding of bash, the examples you gave show similarity with some regular expression syntax, which in turn gives some context to regular expression syntax, so that it does not seem to be quite so foreign a language.

Comment #2 posted on 2015-10-27T19:49:37Z by Dave Morriss

Thanks Frank, glad you enjoyed it

The regular expression subject is a complex one. I've been wondering whether I should try and pass on what I know about it.

Strictly this brace expansion topic is in the area of using patterns to match filenames. Confusingly this is similar but not the same as regular expressions. In later episodes in this (not-)series I want to talk more about filename matching then look at regular expressions in the context of Bash.

Really, the regular expression subject could (should?) be stand-alone and should look at what's available in Bash, grep, sed, awk, etc. I use Perl regular expresions the most but I hesitate to go too deep there because they are mind-blowing :-)

Comment #3 posted on 2015-10-28T22:01:14Z by Frank

Indeed regular expressions are complex. They make my brain hurt.

Seeing some kinship with shell commands--some indication that whoever perpetrated regex did not just make it up from the whole cloth--is somehow comforting.

I recently stumbled over a great *beginner's* tutorial.

What makes it so good is that it uses the GPL text found on every Linux computer for the exercises, so you can practice the examples and try different options as you read along.

Comment #4 posted on 2015-10-29T11:44:38Z by Dave Morriss

Regular expressions

I skimmed through that tutorial, and it looks very good. Thanks for the pointer.

<< First, < Previous, Latest >>

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?