Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-18-2008, 11:28 PM   #1
LQ Newbie
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
How to parse in korn shell

Guys, I am having a problem, I have been using ksh script on my aix 52 that parse from the line and give me the file name but but when i try to use the same script on 5.3 it failed to parse,

here is my script line and sample output



echo $FileName

output should be "rfdc0xk_0418152945" but it is showing me the whole line

any idea how can i fix or if there is any other way to get the same result please help me

Old 04-19-2008, 08:06 AM   #2
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
What you're trying to do is parameter expansion - substrings (yeah, yet another strange name for something). The general form is
${parameter#pattern} remove small left pattern
${parameter##pattern} remove large left pattern
${parameter%pattern} remove small right pattern
${parameter%%pattern} remove large right pattern
print ${InterfacFile##*/}
The trick is the "##*/"

Hope this helps


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
korn shell: scripting an or for if..then Harry Seldon Linux - General 2 01-10-2008 05:21 PM
Globbing using Korn Shell metallica1973 Programming 1 12-05-2007 05:56 PM
Korn shell and Arrays jpc82 Programming 1 06-28-2005 03:27 AM
install korn shell namgor Linux - Newbie 1 07-12-2004 03:52 PM
a t&t korn shell 93 shook Linux - Software 4 02-01-2003 02:54 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:45 PM.

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