Bash getting the parent folder name from a bash defined variable

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have defined a variable in a bash script (ie MY_FOLDER) but you also want to dynamically get the parent folder (ie MY_FOLDER can have multiple values).

Solution

Use the dirname as in the following

Removing a range of history lines from bash history

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You would like to remove some lines from the bash history (ie using cut and paste with wrong values).

Solution

You can use the following, taken from the answer here

where start_line is the start of the lines you want to remove and no_of_lines is the number of lines you want to be removed.