text processing ( sed/awk)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting text processing ( sed/awk)
# 8  
Old 02-29-2008
Quote:
Originally Posted by anchal_khare
very thanks for evy1 soln....
'll use any of thm...

1 request .. can any1 chk the vino's soln.. why its nor working...
logic seems to be current,,, but i cunt find out the error...

thanks again..

anchal.
sed will output the changes to stdout. It will not make the changes permanent to the file unless you tell it to.

If you sed supports the -i flag use
Code:
sed -i -e "s/.\{400\}/&\n/g" file.txt

If not
Code:
sed -e "s/.\{400\}/&\n/g" file.txt >out.txt

out.txt will contain the desired output.
# 9  
Old 02-29-2008
hi vino...
yes i knw what u told....

the output ( stdout ) is unchanaged...
have u tested ur command.. ?
# 10  
Old 02-29-2008
Quote:
Originally Posted by anchal_khare
hi vino...
yes i knw what u told....

the output ( stdout ) is unchanaged...
have u tested ur command.. ?
Code:
[/tmp]$ cat t
abcdefghijklmopqrstuvwxyz
[/tmp]$ sed -e "s/.\{4\}/&\n/g" t
abcd
efgh
ijkl
mopq
rstu
vwxy
z
[/tmp]$

Try
Code:
sed -e "s/.\{4\}/&\\n/g" t

# 11  
Old 02-29-2008
wondered... !!!
the same goes here with unchanged o/p.

-bash-2.05b$ cat 400.txt
abcdefghijklmopqrstuvwxyz

-bash-2.05b$ sed -e "s/.\{4\}/&\n/g" 400.txt
abcdnefghnijklnmopqnrstunvwxynz


also tried double escaped.. :-)

what cud be the reasonn..??

now i tried on linux..

it working...
what cud be the prob with HP-UX?
# 12  
Old 02-29-2008
deleted.
reason : duplicate post.
# 13  
Old 02-29-2008
version inconsistincies with handling newlines in RH side of substitution...

It does work for anything other than \n in Solaris sed also:

Code:
#  sed -e "s/.\{4\}/&%/g" infile
abcd%efgh%ijkl%mopq%rstu%vwxy%z

So...a workaround:
Code:
#  sed -e "s/.\{4\}/&%/g" infile | tr "%" "\n"
abcd
efgh
ijkl
mopq
rstu
vwxy
z

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk for text processing

Hi,my file is in this format ", \"symbol\": \"Rbm38\" } ]" I want to convert it to a more user readable format _id pubmed text symbol 67196 18667844 Overexpression of UBE2T in NIH3T3 cells significantly promoted colony formation in mouse cell cultures Ube2t 56190 21764855 ... (3 Replies)
Discussion started by: biofreek
3 Replies

2. Shell Programming and Scripting

Text replacement with awk or sed?

Hi guys, I worked for almost a half-day for the replacement of some text automatically with script. But no success. The problem is I have hundred of files, which need to be replaced with some new text. It's a painful work to work manually and it's so easy to do it wrong. For example, I... (2 Replies)
Discussion started by: liuzhencc
2 Replies

3. Shell Programming and Scripting

Text columns processing using awk

P { margin-bottom: 0.25cm; line-height: 120%; }CODE.cjk { font-family: "WenQuanYi Micro Hei",monospace; }CODE.ctl { font-family: "Lohit Hindi",monospace; }A:link { } I'm trying to build an awk statement to print from a file (file1): A 1,2,3 * A 4,5,6 ** B 1 ... (4 Replies)
Discussion started by: dovah
4 Replies

4. Shell Programming and Scripting

Text processing using awk

I dispose of two tab-delimited files (the first column is the primary key): File 1 (there are multiple rows sharing the same key, I cannot merge them) A 28,29,30,31 A 17,18,19 B 11,13,14,15 B 8,9File 2 (there is one only row beginning with a given key) A 2,8,18,30,31 B ... (3 Replies)
Discussion started by: dovah
3 Replies

5. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

6. Shell Programming and Scripting

Awk text processing

Hi Very much appreciate if somebody could give me a clue .. I undestand that it could be done with awk but have a limited experience. I have the following text in the file 1 909 YES NO 2 500 No NO . ... 1 ... (8 Replies)
Discussion started by: zam
8 Replies

7. Shell Programming and Scripting

text transformation with sed or awk

Hi there, I'm trying to extract automatically opening hours from a website. The page displaying the schedules is http://www.natureetdecouvertes.com/pages/gener/view_FO_STORE_corgen.asp?mag_cod=xxx with xxx going from 101 to 174 I managed to get the following output : le lundi de 10.30 à... (4 Replies)
Discussion started by: chebarbudo
4 Replies

8. Shell Programming and Scripting

awk, perl Script for processing a single line text file

I need a script to process a huge single line text file: The sample of the text is: "forward_inline_item": "Inline", "options_region_Australia": "Australia", "server_event_err_msg": "There was an error attempting to save", "Token": "Yes", "family": "Family","pwd_login_tab": "Enter Your... (1 Reply)
Discussion started by: hmsadiq
1 Replies

9. Shell Programming and Scripting

Preparing LaTeX files using Sed/AWK for processing with latex2html

As the title states, my issue involves preparing LaTeX documents for processing with latex2html. Within my LaTeX docs I have used a package which allows me to cleanly display source code listings. However the package is not supported by latex2html which, when processed, does not display the... (3 Replies)
Discussion started by: oski
3 Replies

10. Shell Programming and Scripting

processing a file with sed and awk

Hello, I have what is probably a simple task in text manipulation, but I just can't wrap my brain around it. I have a text file that looks something like the following. Note that some have middle initials in the first field and some don't. john.r.smith:john.smith@yahoo.com... (4 Replies)
Discussion started by: manouche
4 Replies
Login or Register to Ask a Question