Edit Text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Edit Text
# 1  
Old 01-07-2011
Edit Text

Hi everyone , i am new in shell scripting and i want to do a simple job.
A have in a file a text that looks like :

4770 maniac 20 0 13680 312 240 S 0.0 0.0 0:00.00 pro 4770 maniac 20 0 23448 312 240 S 0.0 0.0 0:00.00 pro 4770 maniac 20 0 33216 312 240 S 0.0 0.0 0:00.00 pro

and i want to break it in three lines:

4770 maniac 20 0 13680 312 240 S 0.0 0.0 0:00.00 pro
4770 maniac 20 0 23448 312 240 S 0.0 0.0 0:00.00 pro
4770 maniac 20 0 33216 312 240 S 0.0 0.0 0:00.00 pro

Any help would be appreciated Smilie
# 2  
Old 01-07-2011
Code:
sed 's/pro[ ]/pro\
/g' inputFile

This User Gave Thanks to anurag.singh For This Post:
# 3  
Old 01-07-2011
AWK....
Code:
awk '{for(i=1;i<=NF;i++){if($i=="pro"){printf $i"\n"}else {printf $i FS}}}'  inputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to edit a text file

hi, could someone share a short script that would process a .txt file and do the following, for example the text file has this form 0:1.0 1:1.0 2:2.0 3:3.0 4:4.0 5:5.0 6:6.0 7:7.0 8:8.0 ... {newline} 9:9.0 10:10.0 11:11.0 12:12.0 13:13.0 14:14.0 15:15.0 16:16.0 17:17.0 ... {newline} and I... (3 Replies)
Discussion started by: c_lady
3 Replies

2. Shell Programming and Scripting

Edit first line of a text file

Hi friends, Issue1: I have a text file with the first line like this #chrom start end Readcount_A Normalized_Readcount_A ReadcountB Normalized_Readcount_B Fc_A_vs_B pvalue_A_vs_B FDR_A_vs_B Fc_B_vs_A pvalue_B_vs_A FDR_B_vs_A <a href="http://unix.com/">Link</a> How can I change it to the... (11 Replies)
Discussion started by: jacobs.smith
11 Replies

3. SCO

How to write/edit text in russian on SCO

Hello. I'm new to unix, and I want to write/edit text files in russian on SCO 5.0.7. Is it possible and how to do this. I tried to add russian support in KDE using kikbd, but unsuccessful. (1 Reply)
Discussion started by: OpG_
1 Replies

4. Shell Programming and Scripting

Open the file and edit/append the text

Hi i have a file like this mailboxnum 20 filename <to subsitute> fileloaction /home/dd234/ filetype txt in a directory i have set of files for ex: TT45.1.2 TT45.1.3 TT45.1.4 . . in for loop i have to take this files and subsitute one by one ex: (1 Reply)
Discussion started by: greenworld123
1 Replies

5. Shell Programming and Scripting

Text editing script does everything but edit text.

I wrote this script to create and edit a large number of websites based on a template site and a collection of text files which have the relevant strings in them delimited by colons. I run it and the shell doesn't produce any errors, but when it gets to the for loop where it actually has to edit... (2 Replies)
Discussion started by: afroCluster
2 Replies

6. UNIX for Dummies Questions & Answers

edit this text file

hi, i need to remove the first column (and dash) from this text file. Is there any unix command allowing me to do it ? 1-16 2-28 3-16 4-20 5- 8 6-32 7-19 8-16 9-27 10- 7 11-14 12-18 thanks (2 Replies)
Discussion started by: aneuryzma
2 Replies

7. Shell Programming and Scripting

Edit other than the first and last record of a text file

Hello, I have to add the string "YES" to the end of all records of files in a dir other than the first(header) and the last(trailer) record. viz, the first and the last record in a file has to be identified and exempted from the edit. I tried an awk script. But there seems to be no direct... (8 Replies)
Discussion started by: rogersed
8 Replies

8. Shell Programming and Scripting

need one liner to edit this text...

# cat test mpath0:253:8:L--w:0:1:2:mpath-2000b080008002158 mpath19:253:7:L--w:0:1:1:mpath-2000b080013002158 mpath21:253:9:L--w:0:1:0:mpath-2000b080015002158 mpath18:253:6:L--w:0:1:1:mpath-2000b080012002158 mpath12:253:1:L--w:0:1:2:mpath-2000b080009002158 # The above is the i/p and the... (3 Replies)
Discussion started by: ilan
3 Replies

9. Shell Programming and Scripting

SED text edit help needed

Could someone please tell me how to delete all lines above a line which contains a particular string? (possibly using SED command) I know how to do this if the target string appears in only one line of file but when it appears in multiple lines it only deletes from the first line which the string... (3 Replies)
Discussion started by: stevefox
3 Replies

10. Shell Programming and Scripting

Edit and insert character in a text file

Hello All, Can somebody please help me how to accomplish the following : I have a text file called data.txt that has the following information : M|88494-998494 M|98jd#0094 M|88394-994049 M|GFG9980#009944 and so on... I need to replace the value of M to either "S" or "X"... (3 Replies)
Discussion started by: negixx
3 Replies
Login or Register to Ask a Question