Variable longpath="/dir1/dir2/dir3/filename.stuff.morestuff.garbage"
I want to end up with just "filename.extra.moreextra". So, I want to get rid of the path and .garbage
I want to do this with just ksh internals. So, no sed,grep,awk,expr, etc...
I can do it with two operations.
How can I combine the two operations into one?
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
The shell ksh does not allow nesting -- like this:
producing:
and dash, bash shells will not allow nesting, however, zsh will:
Best wishes ... cheers, drl
TYVM rdcwayx and drl.
I guess if I was going to use it enough and I am really 'lana' about using ksh internals, I could just write a function like this.
I think you're doing the right thing by gravitating towards ksh internal commands. This can really speed up your script by avoiding external processes. But you should not worry about using extra lines of code to accomplish this. It is still much faster than the overhead of forking another process. And rememeber that ksh compiles as it runs just like perl. If those two statements are in a loop, they will be read once... not once per iteration.
Hi Guys,
I am trying to format my csv file. When I spool the file using sqlplus the single row output is wrapped on three lines.
Somehow I managed to format that file and finally i am trying to make the multiple line on single line.
The below command is working fine but I need to pass the... (3 Replies)
Hi friends,
I have a some files in a directory. for example
856-abc
856-def
851-abc
945-def
956-abc
852-abc
i want to display only those files whose name starts with 856* 945* and 851* using a single pattern.
i.e
856-abc
856-def
851-abc
945-def
the rest of the two files... (2 Replies)
I am facing a problem and I would be grateful if you can help me :wall:
I have a list of words like
And I have a datafile like
the box of
the box of tissues out of
of tissues out of
the book, the
the book, the pen and the
the pen and the
I want to find Patterns of “x.*x” where... (2 Replies)
Hi ,
I have a file which has multiple rows of data, i want to match the pattern for two columns and if both conditions satisfied i have to add the counter by 1 and finally print the count value. How to proceed...
I tried in this way...
awk -F, 'BEGIN {cnt = 0} {if $6 == "VLY278" &&... (6 Replies)
Hello sorry for the probably simple question - searching about the forums and Internet, I have not found the answer.
Could you tell me please how to do a multiple pattern match with SED
So it would be SED searching for "PATTERN1" 'or' "PATTERN2" not 'and' if they happen to fall on the same... (4 Replies)
Hi everyone, and thank you for your help with this. I am VERY new with perl so all of your help is appreciated. I have tried google but as I don't know the proper terms to search for and could be daunting for a newbie scripter... I know this is very easy for most of you! Thanks!
I have a... (4 Replies)
I've got a longish log file with content such as
Uplink traffic:
Downlink traffic:
I want to parse the log file and remove any line that contains the string "Uplink traffic:" at the beginning of the line, but only if the line following it beginnings with the string "Downlink traffic:" (in... (7 Replies)
I try to use the pattern substitution operators as documented in the O'Reilley "Learning the Korn Shell" but it doesn't seem to work as advertised.
This works all right:
var='Regular expressions rules!'
$ echo ${var//e/#}
R#gular #xpr#ssions rul#s!
The docs says that using !(expr)... (5 Replies)