Shell Flashcards

1
Q

What does ${PWD##*/} do?

A

Finds the longest match of */ starting at the beginning of the string, and removes it. So just the current directory name, not absolute path.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does ${file%.*} do?

A

Finds the shortest match of .* (which may just be a . ) starting from the end of string and going backwards, and removes it. Most likely this strips an extension (.mp3, .txt, etc).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly