Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Find a string across line break (because of "segmentation fault core dumped") Post 302926341 by derekludwig on Sunday 23rd of November 2014 01:34:37 PM
Old 11-23-2014
Wizard,

Just to confirm, using RS="" was to read in stanzas - groups of lines separated by blank lines. Or are you trying to read in the entire file at once? The latter is what you are trying to do with:
Code:
cat test.txt | xargs |sed -e 's/ //g' > test2.txt

which really should be:
Code:
tr -d '\n' < test.txt > test2.txt

This is because xargs will join the lines of text until the maximum number of arguments or maximum command line length is reached.
Perl's file slurping may be useful here:
Code:
perl -e '$/ = undef; $\ = "\n"; $, = " "; $_ = <>; s{\s+}{}g; push @X, pos while m{jkl}gi; print @X;'

which generates:
Code:
11 20 23 30 38 69 80 92 99 107 121 132

for the followig input file:
Code:
AAAAAGHI
JKLAjKMEFJK
LjklABCDJkLEFGHIJKL

ZZAjdskljfdAAAAGHI
ldjkflfsdkJKLAjKMEFJK
jklfsdkjfsdLjklABCDJkLEFGHIJKL

dAAAAGHI
ldkJKLAjKMEFJK
jklfklAB

---------- Post updated at 01:34 PM ---------- Previous update was at 01:31 PM ----------

Or if you don't mind each indice being on a separate line, this is slightly simpler:
Code:
perl -e '$/ = undef; $\ = "\n"; $_ = <>; s{\s+}{}g; print pos while m{jkl}gi;'

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Segmentation fault (core dumped)

Hello To All! Now anfd then I receive a message on my console: Segmentation fault (core dumped) What does it mean? Or more precisely what are the implications? :confused: (1 Reply)
Discussion started by: Ivo
1 Replies

2. Programming

What is an "Illegal Instruction -Core Dumped"

Hai! i am working on Digital UNIX V3.2c Work station, my program uses Pro*C, C and X-Motif calls. i am facing problem while running application saying "Illegal Instruction Core Dumped". debugger dbx shows error at a line which shows "noname". when commenting large portion of the code it runs... (1 Reply)
Discussion started by: samn
1 Replies

3. Programming

why tell "core dumped"?

why tell core dumped? I am a new .I write a program.I use cc to complier it. when i run it,it tell me "core dumped"? who can tell me the reason? the program as follow: main() { char *a; printf("please input your name:"); scanf("%s",a); printf("\n"); printf("%s",a); } (3 Replies)
Discussion started by: fresh
3 Replies

4. Programming

Segmentation Fault (core dumped)

what r the situations to receive an error msg like the one below Segmentation Fault (core dumped) (2 Replies)
Discussion started by: bankpro
2 Replies

5. Solaris

Segmentation Fault (core dumped)

i am getting Segmentation Fault (core dumped) on solaris, but when i run the same program with same input on linux it runs successfully. How can i trace the fault in program on solaris. (6 Replies)
Discussion started by: junaid.nehvi
6 Replies

6. Solaris

segmentation fault core dumped

i am getting segmentation fault (core dumped) i tried following things but couldn't understand what is wrong with my prog and where the problem is.... i have only adb debugger available on solaris.... so plz help bash-3.00$ pstack core core 'core' of 765: ./mod_generalised_tapinread... (4 Replies)
Discussion started by: junaid.nehvi
4 Replies

7. Red Hat

Segmentation fault (core dumped)

Hi All, I am getting "Segmentation fault (core dumped)" error in the runtime. I am new this please can you tell me why is that i am getting this error and I am not sure of my compilation : gcc -c avc_test.c gcc -c md5.c gcc avc_test.o md5.o -shared -Llibcoreavc_sdk.so -o proj ... (1 Reply)
Discussion started by: fido.genial
1 Replies

8. Programming

getting Segmentation Fault (core dumped) error but Program runs fine.

i am executing following program int main() { char str; FILE * fp; int i=0; ... (4 Replies)
Discussion started by: bhavesh.sapra
4 Replies

9. UNIX for Advanced & Expert Users

Segmentation Fault/ core dumped in metadb

When I was trying to mirror in my v880 server after OS up gradation from 8 to 10 metadb -afc 3 /dev/dsk/c1t1d0s7 I got an error metadb: Segmentation Fault Segmentation Fault (core dumped) Then I logged a case to Oracle/sun team they suggest "Please could you try metadb -ac 3... (0 Replies)
Discussion started by: taherahmed
0 Replies

10. UNIX and Linux Applications

Tilda Segmentation fault (core dumped)

Can anyone tell me why I keep getting a Segmentation fault when I try to run tilda? $ tilda Segmentation fault (core dumped) It seemed to run after I deleted my tilda directory like this thread said to do. Unfortunately it wouldn't let me set my keybinding with anything I tried. ... (0 Replies)
Discussion started by: cokedude
0 Replies
break(1T)						       Tcl Built-In Commands							 break(1T)

__________________________________________________________________________________________________________________________________________________

NAME
break - Abort looping command SYNOPSIS
break _________________________________________________________________ DESCRIPTION
This command is typically invoked inside the body of a looping command such as for or foreach or while. It returns a TCL_BREAK code, which causes a break exception to occur. The exception causes the current script to be aborted out to the innermost containing loop command, which then aborts its execution and returns normally. Break exceptions are also handled in a few other situations, such as the catch com- mand, Tk event bindings, and the outermost scripts of procedure bodies. EXAMPLE
Print a line for each of the integers from 0 to 5: for {set x 0} {$x<10} {incr x} { if {$x > 5} { break } puts "x is $x" } SEE ALSO
catch(1T), continue(1T), for(1T), foreach(1T), return(1T), while(1T) KEYWORDS
abort, break, loop ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl break(1T)
All times are GMT -4. The time now is 02:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy