Sponsored Content
Full Discussion: How to edit a txt file ?
Top Forums Shell Programming and Scripting How to edit a txt file ? Post 302200852 by joeyg on Friday 30th of May 2008 08:33:24 AM
Old 05-30-2008
Hammer & Screwdriver Be careful of spacing

Not sure of your problem, but spacing could have been an issue around certain commands. At any rate, the following command and result is what I just got (I am using bash):
Code:
> cat data.txt | cut -c4-200 | cut -f1-8 | tr "\t" "|"
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

To send to a file, just add the appropriate command at the end of the line:
cat data.txt | cut -c4-200 | cut -f1-8 | tr "\t" "|" >processed_data.txt
 

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
drv(1)                                                              Apple Inc.                                                              drv(1)

NAME
drv - cups driver interface for ppd compiler files SYNOPSIS
drv list drv cat drv:///filename.drv/pcfilename DESCRIPTION
drv lists and compiles PPDC source files installed in the /usr/share/cups/drv and (on Mac OS X) /Library/Printers/PPDs/Contents/Resources directories on behalf of the scheduler, cupsd(8). The first form of the command lists all of the PPD files that can be produced by the driver information files in the two directories. The second form of the command compiles the requested PPD and sends it to the standard output. SEE ALSO
ppdc(1), ppdhtml(1), ppdi(1), ppdmerge(1), ppdpo(1), ppdcfile(5) http://localhost:631/help COPYRIGHT
Copyright 2008-2009 by Apple Inc. 9 March 2009 CUPS drv(1)
All times are GMT -4. The time now is 03:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy