The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Help with awk script, changing the FS for a single variable sx3v1l_1n51de Shell Programming and Scripting 3 11-18-2008 04:59 PM
display changing variable in one place on screen in ksh raidzero Shell Programming and Scripting 7 09-25-2008 09:24 AM
rerun .profile after changing variable sboxtops AIX 2 09-02-2008 02:19 PM
IFS changing the variable value pvar Shell Programming and Scripting 1 02-25-2005 06:21 PM
Very simple question about changing PS1 variable at startup! abidmalik UNIX for Dummies Questions & Answers 2 08-26-2002 01:05 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-12-2009
Pablo_beezo Pablo_beezo is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 85
Changing a variable Question

I have a variable:

$FILENAME = /XXXX/XXXX/XXXX/file.dat

I want to set another variable that will give me this:

$FILENAME2=filea.dat

So basically i'm chopping up variable $FILENAME.

Not sure cut will do this as i'm looking at different directories so the characther length may be different e.g.

$FILENAME = /server1/test/data/file.dat
or
$FILENAME = /server17/dept_area/test/data/file.dat


What are the best way's to do this?

Last edited by Pablo_beezo; 02-12-2009 at 10:51 AM..
  #2 (permalink)  
Old 02-12-2009
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
man basename
Code:
basename $FILENAME
file.dat
  #3 (permalink)  
Old 02-12-2009
curleb curleb is offline
Registered User
  
 

Join Date: Mar 2008
Location: Here, in my Ivory Tower...
Posts: 68
Learn more about it with
Code:
man basename
and
Code:
man dirname
, plus learn to use ksh built-ins such as:

Code:
#  Make a name for yourself... 
   typeset -l my_name=${0##*/} 
   typeset    my_path=${0%/*}
Closed Thread

Bookmarks

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 01:25 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