Hey all, I'm writing a program which saves the output to a single file like "output.txt"
I've been playing with the ios::nocreate and ios::noreplace but I can't get it to quite do what I want it to do (and yes I've included the #include <iostream> to activate them.
What I'm trying to do is...
Is this possible?
I want to have my awk script check to make sure the input file is a text file? I've been having a heck of a time trying to do this. I've been trying variations on the system command such as:
(system("file " FILENAME)==*"text"*)
to no avail. Any ideas?
Thanks in...
I was working something along those lines, but was afraid it would have caused errors, but alas this works like a champ! I'm getting some other unexpected outputs now, but it's something I can quash pretty quick!
Thanks again CaKiwi!
Here's what I'm trying to do.
I'm printing a pattern out of a source file by matching it using:
nawk'
.
.
.
/start_string/,/stop_string/{print > output.file}
.
.
.
' input.file
Sample input.file
.
.
.
1111blah
1112blah
1113blah
1114header information 1
1115header information 2
1116blah...
Ygor, that worked! Thank you very much.
Vlad, thanks for the idea for streamlining the code, I'll working on that now too! Having to account for all my "{}"s
Scott
Okay, still stuck...
Here's the file I'm processing with my awk/nawk code:
11111111111111 dont want
11111111111112 start.*101-01
11111111111113 file 1 text
11111111111114 stop
11111111111115 dont want
.
.
.
What the code is supposed to do is create a file called...
I thought I must be close. I tried what vlad had, exept for the ()s. I'll try that when I'm back at the office and let ya'll know how it works... I don't feel too bad since I was close on my first try at it, but alas, close only counts in horseshoes, hand grenades, and slow dancing -- but not...
In my awk script I would like to print a file to a subdirectory created by variables.
instead of the command {print >> file} to print to a file in the current directory I'd like to send it to:
/subdirectory1/subdirectory2/file
where subdirectory1 and subdirectory2 are previously defined...
Futurelet-
I don't need ++prefix when it's all said and done. I was using that to simulate the incrimenting numbers for creating several files. I'm new to the whole awk thing, and my programming skills are rusty so I neglected to clean that up before I posted.
That code got me close enough...
I have another problem. I'm trying to extract a string to be used as part of a new file's name. For each type I know either the format of or the placement of the text.
I can't use $1 for pulling out the numerical reference since there may or may not be a space at the end of the character...
Jean Pierre, thanks for the quick response! but I'm still getting the same problem:
awk: too many output files 10
record number 42
If it matters, I'm running Korn Shell.
Here is my modified script, sould be identical to yours unless I'm missing something:
awk '
BEGIN{prefix=100 }...
Hey all, newbie to awk here.
I'm trying to write an awk command that will split test out of a larger file and put it into smaller files based on start and stop sequences. I'm running into the system limitation of 10 files open and can't get the close() command to work. Any help is...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.