Computing.Net > Forums > Unix > Need to find the string

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need to find the string

Reply to Message Icon

Name: ahmedwaseem2000
Date: July 7, 2005 at 08:23:11 Pacific
OS: Unix
CPU/Ram: 256
Comment:

Hi ,

Can any one of you tell me how to find the 5 characters after the 5th occurance of a ","(comma) in a data file for all the rows of the file. As i am still naive with unix scripting

Many Thanks,
Waseem



Sponsored Link
Ads by Google

Response Number 1
Name: vicchai
Date: July 7, 2005 at 19:00:14 Pacific
Reply:

Hi Waseem,

If you means all occurance in one line, you can try this:

tr "," " " < datefile | awk '{print $6}' | cut -c 5



0

Response Number 2
Name: ahmedwaseem2000
Date: July 7, 2005 at 22:40:06 Pacific
Reply:

Hi Victor,

Thanks for all your help. May i ask you for one more favor if possible for you. now i have 2 files one data file and the other parameter file. from parameter file i have to pick a value and perform some calculations and place it at the end of the corresponding line number in the data file.

Could you please help again.

Many Thanks,
Waseem


0

Response Number 3
Name: Jim Boothe
Date: July 8, 2005 at 08:37:29 Pacific
Reply:

FYI, the tr solution above that changes the comma-delimited data to space-delimited data will fail when the data contains spaces such as:

15023,Jim Boothe,123 Main Street,O-positive

Just let awk process it as comma-delimited data:

awk -F, '{print $6}' datafile | cut -c-1-5


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Need to find the string

to append the end of a line www.computing.net/answers/unix/to-append-the-end-of-a-line/6100.html

Need to convert the date in a SQUID www.computing.net/answers/unix/need-to-convert-the-date-in-a-squid/3877.html

how to find the number of defunc process www.computing.net/answers/unix/how-to-find-the-number-of-defunc-process/2308.html