The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
edit a file using ksh meghana Shell Programming and Scripting 3 04-16-2008 11:04 AM
Edit value in File sewood Shell Programming and Scripting 1 03-18-2008 02:11 AM
How to edit env file duke0001 UNIX for Advanced & Expert Users 3 02-16-2007 11:43 AM
file edit help sentak Shell Programming and Scripting 10 11-14-2006 08:20 AM
Edit an ISO / dd file? WIntellect Filesystems, Disks and Memory 4 11-20-2002 05:21 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-30-2008
RRVARMA's Avatar
RRVARMA RRVARMA is offline
Registered User
  
 

Join Date: Feb 2008
Location: Bangalore, INDIA
Posts: 34
Exclamation How to edit a txt file ?

Hi,

I need to edit a text file which is like this..

Code:
-- D3341000600	AGEC901164   XYZ	SE0109	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3341000600	AGEC901164   XYZ	SE0109	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3341006000	AGEC921472   XYZ	SE0109	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3341006000	AGEC921472   XYZ	SE0109	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3213716600	DCEC160720   XYZ	RZ9191	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3213716600	DCEC160720   XYZ	RZ9191	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3213716300	DCEC169043   XYZ	RZ9191	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3213716300	DCEC169043   XYZ	RZ9191	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3213716100	DCEC197234   XYZ	RZ9191	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
-- D3213716100	DCEC197234   XYZ	RZ9191	1RNVX	AH	2009-01-19	2009-01-11	2009-01-21
I need to get it like this..

Code:
 D3341000600|AGEC901164   XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3341000600|AGEC901164   XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3341006000|AGEC921472   XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3341006000|AGEC921472   XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3213716600|DCEC160720   XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3213716600|DCEC160720   XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3213716300|DCEC169043   XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3213716300|DCEC169043   XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3213716100|DCEC197234   XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
 D3213716100|DCEC197234   XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
I tried with this code.. but its not working.. the script is not terminating.. and the log file is empty..

Code:
#!/bin/ksh


for name in `cat data.txt`
do
cat $name |cut -f2,3,4,5,6,7,8,9|tr '\t' '|' > processed_data.txt
done

if [ $? -eq 0] ; then echo " Prcocessing completed."
else echo "script failed"
fi
Please help..

Thanks,
RRVARMA
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0