LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-09-2010, 12:32 AM   #1
Crowey
Member
 
Registered: Jun 2006
Location: Perth, WA
Distribution: RHEL
Posts: 36

Rep: Reputation: 16
Problem With Shell Script Variable Usage


Gidday, shell scripting newbie, and having real problem with below:

DUMMY=$MYFILE | cut -c 11- | cut -c -8 | tr -d -

If I do:

echo $MYFILE | cut -c 11- | cut -c -8 | tr -d -

I get the result I want (a file in format of <name><yyyy>-<mm>-<dd>.zip cut down to just yymmdd); but not if I try to set it as a variable ...

Is it something stupid I'm doing, or is it more complicated than I thought?

Any help would be greatly appreciated.

Cheers
John
 
Old 02-09-2010, 12:44 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Code:
DUMMY=$(echo $MYFILE | cut -c 11- | cut -c -8 | tr -d - )
 
1 members found this post helpful.
Old 02-09-2010, 01:03 AM   #3
Crowey
Member
 
Registered: Jun 2006
Location: Perth, WA
Distribution: RHEL
Posts: 36

Original Poster
Rep: Reputation: 16
Thanks

Quote:
Originally Posted by chrism01 View Post
Code:
DUMMY=$(echo $MYFILE | cut -c 11- | cut -c -8 | tr -d - )
Worked a treat - thank you VERY much!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
pass variable from one shell script into another shell script xskycamefalling Programming 9 10-03-2009 01:45 AM
Bash/Shell: Problem using a variable in a script redvivi Linux - General 8 08-21-2008 02:02 PM
Problem with shell script using a variable from a unix command. abefroman Programming 1 05-10-2006 02:14 PM
problem with sed n variable in shell script dipenchaudhary Programming 4 02-12-2006 10:54 PM
Odd problem with making a variable the output of a command in a shell script linux=future Programming 3 12-13-2005 09:45 PM


All times are GMT -5. The time now is 10:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration