The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
CHMOD DOS Filenames moondogi UNIX for Dummies Questions & Answers 1 11-02-2008 11:13 PM
spaces in filenames, for do naviztirf Shell Programming and Scripting 4 10-17-2007 06:08 PM
tar contains duplicate filenames dangral UNIX for Dummies Questions & Answers 2 03-14-2007 04:18 PM
How to concatenate two strings or several strings into one string in B-shell? fontana Shell Programming and Scripting 2 08-26-2005 12:58 PM
searching for filenames with search strings in another file pathanjalireddy Shell Programming and Scripting 3 06-08-2005 06:35 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-25-2009
coupestyle coupestyle is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
Need help with getting filenames from url strings

I've been trying to figure out how to extract filenames (with extensions) from a variable that contains a series of URL strings that won't necessarily be the same length or contain the same number of paths as part of a bash shell script. For example

Code:
#!/bin/bash

URLS="http://www.domain.com/folder/filename.tar.gz http://www.anotherdomain.com/folder/subfolder/file.tar.gz"

for url in ${URLS}
do
  echo $url
done
exit 0
This outputs each of the URLs in turn, which is fine, but I'd need to be able to output just the filename and extension (eg. filename.tar.gz or file.tar.gz) - everything after the last forward slash but I haven't had any luck in getting anything close to working. Any assistance is greatly appreciated!

Last edited by coupestyle; 08-25-2009 at 01:25 PM..
 

Bookmarks

Tags
url string filename

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0