FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

LinkBack Thread Tools
Old 02-01-2012, 08:15 PM
Nils Kassube
Default Bash substrings – just can’t figure it out…

Johnny Rosenberg wrote:
> Slightly off topic:
> I am still a bit proud over that I figured out a way to get the album
> artist out of the path to the flac file. The path looks something
> like this:
> Folder="/some/subfolders/and/some/more/subfolders/then/artist/album"
> The artist is always the last but one level of the path, but the
> total number of levels may vary.
> So here is my one-liner, using awk:
> Artist=$(echo "$Folder" | awk -F "/" '{print $((NF-1))}')
> Took me a while to figure out how to use $NF in the print statement.
> Of course I have no doubts that there is a better solution, so if you
> have one, please share. I love to learn! Still a newbie though.

How about this?

Artist=$(basename $(dirname "$Folder"))


ubuntu-users mailing list
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Thread Tools

All times are GMT. The time now is 01:36 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org