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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
checking parameter values passed to script ammu UNIX for Dummies Questions & Answers 2 10-05-2007 09:35 AM
Manipulate files tonet Shell Programming and Scripting 0 09-26-2007 01:04 AM
how do I make dynamic parameter names? Or get the value of a parameter evaluated twi Awanka Shell Programming and Scripting 2 04-19-2007 06:37 PM
How to manipulate the output ??? csaha Shell Programming and Scripting 2 12-23-2005 02:03 AM
How to manipulate date? phani Shell Programming and Scripting 5 04-06-2005 11:17 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-11-2007
Registered User
 

Join Date: Jul 2006
Posts: 26
Stumble this Post!
manipulate a passed in parameter

I am passing a file name as a parameter to shell script
the parameter is getfile.txt.gpg

how do i process this parameter to get name like getfile.txt only and eleminate the .gpg text??

Thanks in advance
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-11-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,837
Stumble this Post!
Try:
Code:
#!/bin/ksh
file="$1"
workfile=${file%*.gpg}
echo "$workfile"
Reply With Quote
  #3 (permalink)  
Old 06-11-2007
Registered User
 

Join Date: Jul 2006
Posts: 26
Stumble this Post!
works fine
Thank you

I tried the following and works fine too

x=`echo $1|wc -c`
y=`expr $x - 5`
z=`echo $1|cut -c1-$y`
echo $z

Thank you


can you explain your code please??
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0