Search Results

Search: Posts Made By: jaldo0805
2,110
Posted By MadeInGermany
This prints the 2nd occurrence: awk...
This prints the 2nd occurrence:
awk '/Sub-header1/ && ++n==2 {flag=1; c=3} /^$/ {flag=0} flag && !(c && --c) {print}' filename.txt
You also can give the search criteria as additional arguments:...
2,110
Posted By MadeInGermany
Below your example; my awk script will print the...
Below your example; my awk script will print the lines with <this
##########
'Header1'
'Sub-header1'
X Y
xxxx.xx yyyy.yyy <this
xxxx.xx yyyy.yyy <this
.... ...
4,697
Posted By shamrock
Change below statement to be > 0 as opposed to >=...
Change below statement to be > 0 as opposed to >= 0...
while ((getline < sprintf("Xfile%04d", file)) > 0) print;
Because when end-of-file is reached the >= 0 test will always be true creating an ad...
2,538
Posted By Scrutinizer
One reason might be that even though it will work...
One reason might be that even though it will work in bash and ksh93, it is not POSIX compliant and so for portability it would be best to use $(cat file)
2,538
Posted By elixir_sinari
Why use cat at all? Use the shell itself...
Why use cat at all? Use the shell itself geo=$(<geom.txt).
2,538
Posted By shamrock
What works for "key" would also work for...
What works for "key" would also work for "geom.txt"...

key=345298
geo=$(cat geom.txt)
cat<<eoi>inpfile
Some standard lines of the program that is going to execute inpfile ....
$key
$geo ...
1,312
Posted By Don Cragun
Note that this form will use up a file descriptor...
Note that this form will use up a file descriptor for every input file processed. Many awk implementations will run out of file descriptors if this script is given more than about 18 files.

If...
1,312
Posted By Jotne
Another solution awk '{$1=$1;print >...
Another solution
awk '{$1=$1;print > FILENAME"_2"}' OFS="\t" file*
This creates new file like file001_2 file002_2 etc.
1,312
Posted By Don Cragun
Close. Try: for i in file??? do awk -v...
Close. Try:
for i in file???
do awk -v OFS="\t" '$1=$1' "$i" > tmp$$
cp tmp$$ "$i"
done
rm -f tmp$$
Almost any command that reads and writes a file using the command line syntax:...
3,262
Posted By Corona688
Actually, it means exactly what it says... Too...
Actually, it means exactly what it says... Too many open files. The close() isn't working for some reason. Memory usage is a nonissue, since we're not actually storing anything in memory.

I...
3,262
Posted By jim mcnamara
awk 'BEGIN{ cnt=1} ...
awk 'BEGIN{ cnt=1}
/Generated/ {ofile=sprintf("file%04d", cnt++) ; next}
/Generated/ && FNR > 1 {close(ofile)}
{print $0 > ofile) } ' ...
Showing results 1 to 11 of 11

 
All times are GMT -4. The time now is 02:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy