?
Solved

String Manipulation in a shell Script

Posted on 2003-02-23
3
Medium Priority
?
256 Views
Last Modified: 2010-04-21
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
Comment
Question by:nirendra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
Vinit Kain earned 100 total points
ID: 8007383
try this

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

0
 
LVL 4

Expert Comment

by:Vinit Kain
ID: 8007389
try this

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

0
 

Author Comment

by:nirendra
ID: 8007485
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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question