Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

String Manipulation in a shell Script

Hi,
I have a string of the format Abc_23-Feb-03_01_01.dat. And I want to remove date part from that string. So it should be Abc_01_01.dat. Can anyone please help me how this can be done in a shell script(ksh).
Thanks,
Nirendra
0
nirendra
Asked:
nirendra
  • 2
1 Solution
 
Vinit KainCommented:
try this

echo $x|cut -f1,3- -d\_

0
 
Vinit KainCommented:
try this

echo Abc_23-Feb-03_01_01.dat|cut -f1,3- -d\_

0
 
nirendraAuthor Commented:
Thanx for ur reply.. anyway I already solved it by using echo ${filename[$i]}|cut -f 1,3,4 -d _ .

But I'm sure your solution will also work.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now