Sponsored Content
Full Discussion: How to edit a txt file ?
Top Forums Shell Programming and Scripting How to edit a txt file ? Post 302200842 by RRVARMA on Friday 30th of May 2008 07:54:00 AM
Old 05-30-2008
Error 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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Edit txt?

Hi! A windows user going UNIX on part time, oh no?!! So my question is how I edit and save documents in UNIX? In DOS you can type 'edit x.txt' to both create a new file and edit a file that already exists. How do I do this in Unix? (2 Replies)
Discussion started by: <Therapy>
2 Replies

2. AIX

How to edit txt file by shell script?

What I want to do is just delete some lines from a text file, I know it's easy using copy and redirect function, but what I have to do is edit this file (delete the lines) directly, as new lines may be added to the text file during this period. Can AIX do this ? # cat text 1:line1 2:line2... (3 Replies)
Discussion started by: dupeng
3 Replies

3. Shell Programming and Scripting

Edit txt file using vi editor

Dear All I have a file called sample.txt which contains as follows HR Files records Loaded RecordDate Unloaded -- ---- -------- --------- ------------ ------ 00 567 77777 67896 0 0 01 345 345567 45678 0 ... (1 Reply)
Discussion started by: tkbharani
1 Replies

4. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

5. Shell Programming and Scripting

command to list .txt and .TXT file

Hi expersts, in my directory i have *.txt and *.TXT and *.TXT.log, *.txt.log I want list only .txt and .TXT files in one command... how to ?? //purple (1 Reply)
Discussion started by: thepurple
1 Replies

6. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

7. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

8. Shell Programming and Scripting

To transpose columns + edit in a txt file

Hi, I have a txt file that looks like log2FoldChange Ontology_term 8.50624450251828 GO:0003700,GO:0003707,GO:0005634,GO:0006355,GO:0043401,GO:0003700,GO:0005634,GO:0006355,GO:0008270,GO:0043565 7.03936870356684 GO:0005515,GO:0008080 6.49606183738682 6.49525073909629 GO:0005515... (4 Replies)
Discussion started by: alisrpp
4 Replies

9. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

10. Solaris

I can't edit a txt file shared from Window server to Solaris

Hello, I'm working with Solaris and I need to share files between Windows Server 2012 and Solaris through an authentication with an Active Directory user, where Windows Server is the "main server". All was going good, until after see the WS files and I tried to open one and modify it, but I cannot... (1 Reply)
Discussion started by: QeratD0
1 Replies
CPG_ZCB_FREE(2009-04-15)												  CPG_ZCB_FREE(2009-04-15)

NAME
cpg_zcb_free - Frees a zero copy buffer #include <corosync/cpg.h> int cpg_zcb_fre(cpg_handle_t handle, void *buffer); DESCRIPTION
The cpg_zcb_free function will free a zero copy buffer. The argument handle describes the handle on which the buffer will be allocated. The argument buffer is the zero copy buffer to free. RETURN VALUE
This call returns the CS_OK value if successful, otherwise an error is returned. ERRORS
The errors are undocumented. SEE ALSO
cpg_overview(8), cpg_initialize(3), cpg_finalize(3), cpg_fd_get(3), cpg_dispatch(3), cpg_join(3), cpg_leave(3), cpg_mcast_joined(3), cpg_membership_get(3) cpg_zcb_alloc(3) cpg_zcb_free(3) cpg_zcb_mcast_joined(3) cpg_context_get(3) cpg_context_set(3) cpg_local_get(3) CS_ERR_TRY_AGAIN Resource temporarily unavailable CS_ERR_INVALID_PARAM Invalid argument CS_ERR_ACCESS Permission denied CS_ERR_LIBRARY The connection failed CS_ERR_INTERRUPT System call inturrupted by a signal CS_ERR_NOT_SUPPORTED The requested protocol/functuality not supported CS_ERR_MESSAGE_ERROR Incorrect auth message received CS_ERR_NO_MEMORY Not enough memory to completed the requested task Corosync Cluster Engine Programmer's Manual corosync Man Page CPG_ZCB_FREE(2009-04-15)
All times are GMT -4. The time now is 08:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy