Sponsored Content
Full Discussion: append to two files
Top Forums Shell Programming and Scripting append to two files Post 302599857 by Corona688 on Sunday 19th of February 2012 01:02:23 AM
Old 02-19-2012
In both cases you should put the '>> outputfile' part outside of awk, after everything else.

That should allow your first awk statement to work.

For the second, perhaps

Code:
awk -v RS=" " '{ print $1 } END { printf("\n"); }' inputfile >>outputfile

This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to append copyright to all files?

I have one file that contain copyright notice, that I would like to append to all files in our directory structure (excluding binaries). How can I do that? Thanks for your help! (3 Replies)
Discussion started by: SiftinDotCom
3 Replies

2. UNIX for Dummies Questions & Answers

append two files

Hi, I have two files where 1 contains data and the other contains strings eg file 1 -0.00000 0.00000 0.00000 0.00000 0.00000 0.80000 0.50000 0.50000 0.60000 0.50000 0.50000 0.20000 -0.00000 0.00000 0.40000 file 2 F F F F F F T T T T T T T T T How to I append file2 to file 1 to... (1 Reply)
Discussion started by: princessotes
1 Replies

3. UNIX for Dummies Questions & Answers

append files as columns

Hi, I will rephrase my question. I have two files: q16 1.341E+05 wf8 3.084E+02 total1 1.344E+05 ud35 5.694E+03 us38 9.367E+05 ya23r 9.414E+02 up23s 2.403E+04 io240 1.203E+04 q16 1.341E+05 wf8 3.084E+02 total1 1.344E+05 ud35 5.694E+03 us38 9.367E+05 (2 Replies)
Discussion started by: f_o_555
2 Replies

4. Shell Programming and Scripting

MV all files and append date

All, I am trying to setup a command that will mv all files in a directory to another location and append a filedate. for example: mv * /location/*'date %y%m%d' Any help? (2 Replies)
Discussion started by: markdjones82
2 Replies

5. Shell Programming and Scripting

Append all files in a folder

Hi All, I have directory in which I have around 50 files with filename as: abcs_1 afaa_2 asda_3 agfa_4 . . sada_50 I want to append all files in sada_50 i.e first ssdd_49 in sada_50. Then append asda_48 in (ssdd_49 in sada_50). As number of files are more I do not feel like... (7 Replies)
Discussion started by: pandeyak
7 Replies

6. UNIX for Dummies Questions & Answers

Append logs to files,

i want to collect new logs only from a existing logfile and the new logs should be written both existing logfile and a new file.. which command i have to use for this. Regards Vijay, (0 Replies)
Discussion started by: vijayq8
0 Replies

7. UNIX for Dummies Questions & Answers

Append Files

Hi All, I have to append 2 lines at the end of a text file. If those 2 lines are already there then do not append else append the 2 lines to the text file. Eg: I have a text file, file.txt This text file might look like this, /home/kp/make.jsp /home/pk/model.jsp I have to append... (1 Reply)
Discussion started by: pavan_test
1 Replies

8. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

9. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

10. UNIX for Beginners Questions & Answers

How to append two fasta files?

I have two fasta files as shown below, File:1 >Contig_1:90600-91187 AAGGCCATCAAGGACGTGGATGAGGTCGTCAAGGGCAAGGAACAGGAATTGATGACGGTC >Contig_98:35323-35886 GACGAAGCGCTCGCCAAGGCCGAAGAAGAAGGCCTGGATCTGGTCGAAATCCAGCCGCAG >Contig_24:26615-28387... (11 Replies)
Discussion started by: dineshkumarsrk
11 Replies
String::BufferStack(3pm)				User Contributed Perl Documentation				  String::BufferStack(3pm)

NAME
String::BufferStack - Nested buffers for templating systems SYNOPSIS
my $stack = String::BufferStack->new; $stack->push( filter => sub {return uc shift} ); $stack->append("content"); $stack->flush_output; DESCRIPTION
"String::BufferStack" provides a framework for storing nested buffers. By default, all of the buffers flow directly to the output method, but individual levels of the stack can apply filters, or store their output in a scalar reference. METHODS
new PARAMHASH Creates a new buffer stack and returns it. Possible arguments include: prealoc Preallocate this many bytes in the output buffer. This can reduce reallocations, and thus speed up appends. out_method The method to call when output trickles down to the bottom-most buffer and is flushed via flush_output. The default "out_method" prints the content to "STDOUT". This method will always be called with non-undef, non-zero length content. use_length Calculate length of each buffer as it is built. This imposes a significant runtime cost, so should be avoided if at all possible. Defaults to off. push PARAMHASH Pushes a new frame onto the buffer stack. By default, the output from this new frame connects to the input of the previous frame. There are a number of possible options: buffer A string reference, into which the output from this stack frame will appear. By default, this is the input buffer of the previous frame. private If a true value is passed for "private", it creates a private string reference, and uses that as the buffer -- this is purely for convenience. That is, the following blocks are equivilent: my $buffer = ""; $stack->push( buffer => $buffer ); # ... $stack->pop; print $buffer; $stack->push( private => 1 ); # ... print $stack->pop; pre_append A callback, which will be called with a reference to the "String::BufferStack" object, and the arguments to append, whenever this stack frame has anything appended to the input buffer, directly or indirectly. Within the context of the pre-append callback, "append", "direct_append", and "set_pre_append" function on the frame the pre-append is attached to, not the topmost trame. Using "append" within the pre-append callback is not suggested; use "direct_append" instead. "set_pre_append" can be used to alter or remove the pre-append callback itself -- this is not uncommon, in the case where the first append is the only one which needs be watched for, for instance. filter A callback, used to process data which is appended to the stack frame. By default, filters are lazy, being called only when a frame is popped. They can be forced at any time by calling "flush_filters", however. depth Returns the current depth of the stack. This starts at 0, when no frames have been pushed, and increases by one for each frame pushed. append STRING [, STRING, ...] Appends the given strings to the input side of the topmost buffer. This will call all pre-append hooks attached to it, as well. Note that if the frame has a filter, the filter will not immediately run, but will be delayed until the frame is "pop"'d, or "flush_filters" is called. When called with no frames on the stack, appends the stringins directly to the "output_buffer". direct_append STRING [, STRING, ...] Similar to "append", but appends the strings to the output side of the frame, skipping pre-append callbacks and filters. When called with no frames on the stack, appends the strings directly to the "output_buffer". pop Removes the topmost frame on the stack, flushing the topmost filters in the process. Returns the output buffer of the frame -- note that this may not contain only strings appended in the current frame, but also those from before, as a speed optimization. That is: $stack->append("one"); $stack->push; $stack->append(" two"); $stack->pop; # returns "one two" This operation is a no-op if there are no frames on the stack. set_pre_append CALLBACK Alters the pre-append callback on the topmost frame. The callback will be called before text is appended to the input buffer of the frame, and will be passed the "String::BufferStack" and the arguments to "append". set_filter FILTER Alters the filter on the topmost frame. Doing this flushes the filters on the topmost frame. filter Filters the topmost stack frame, if it has outstanding unfiltered data. This will propagate content to lower frames, possibly calling their pre-append hooks. flush If there are no frames on the stack, calls "flush_output". Otherwise, calls "flush_filters". flush_filters Flushes all filters. This does not flush output from the output buffer; see "flush_output". buffer Returns the contents of the output buffer of the topmost frame; if there are no frames, returns the output buffer. buffer_ref Returns a reference to the output buffer of the topmost frame; if there are no frames, returns a reference to the output buffer. Note that adjusting this skips pre-append and filter hooks. length If "use_length" was enabled in the buffer stack's constructor, returns the number of characters appended to the current frame; if there are no frames, returns the length of the output buffer. If "use_length" was not enabled, warns and returns 0. flush_output Flushes all filters using "flush_filters", then flushes output from the output buffer, using the configured "out_method". output_buffer Returns the pending output buffer, which sits below all existing frames. output_buffer_ref Returns a reference to the pending output buffer, allowing you to modify it. clear Clears all buffers in the stack, including the output buffer. clear_top Clears the topmost buffer in the stack; if there are no frames on the stack, clears the output buffer. out_method [CALLBACK] Gets or sets the output method callback, which is given content from the pending output buffer, which sits below all frames. SEE ALSO
Many concepts were originally taken from HTML::Mason's internal buffer stack. AUTHORS
Alex Vandiver "alexmv@bestpractical.com" LICENSE
Copyright 2008-2009, Best Practical Solutions. This package is distributed under the same terms as Perl itself. perl v5.10.1 2010-01-06 String::BufferStack(3pm)
All times are GMT -4. The time now is 10:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy