Sponsored Content
Top Forums Shell Programming and Scripting How to replace some content of a file and write with a new name Post 302371540 by mwrg on Sunday 15th of November 2009 01:54:38 PM
Old 11-15-2009
Thanks buddy Smilie one more thing. How can i add a new line before the third line (Which is PRESERVE BLANKS) so the new file will look like this

LOAD DATA
INFILE '/home/scott/XXX.dat'
<New Line>
PRESERVE BLANKS
.............
.............
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace a string with content from another file

Hi, I'm a newbi in shell script. Here what I want to do: FileA: bor bor bor xxxx bib bib bi FileB: something something something I want to replace string "xxxx" in FileA with contents of FileB. i tried with sed: fileb=`cat FileB` reg=xxxx file=FileA (4 Replies)
Discussion started by: afatguy
4 Replies

2. Shell Programming and Scripting

SED to replace file content

Hi, I want to replace _F* by _F in a xml file. what is the sed command. I have tried sed "s/_F$/_F/g" or sed "s/_F*/_F/g" , but it does not work. thx file content <TAG>KC_FOU</TAG> <TAG>KC_FABC</TAG> <TAG>KC_FABCDG</TAG> desire output <TAG>KC_F</TAG> <TAG>KC_F</TAG> <TAG>KC_F</TAG> (6 Replies)
Discussion started by: godfreyyip
6 Replies

3. Shell Programming and Scripting

Replace file content after checking value

Our system is receiving one feed from the third party. One of the field in the flat file is ID which id from position 19 to 27. In some cases this ID is coming as 9 zeros (000000000) or 1 right padded zero. ( 0) For these specific records I want to replace fthis field with blank... (3 Replies)
Discussion started by: varunrbs
3 Replies

4. Shell Programming and Scripting

Need to replace particular content in a xml file

Hi, My requirement is to find a text and replace it with another in a XML file. I am new to Unix,Please provide some suggestion to achieve. Find: <Style ss:ID="ColumnHeader1"> Replace with: <Style ss:ID="ColumnHeader1"> <Borders> <Border ss:Position="Bottom"... (4 Replies)
Discussion started by: cnraja
4 Replies

5. Shell Programming and Scripting

How can I write the specific content in the file through shell script

Hello, I need to do one thing that my script creates the file touch release.SPLASH_12_03_00_RC01.txt Now I want to update that file with some content e.g splashbuild::SPLASH_12_17_00_RC02.zip Thanks (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

6. Shell Programming and Scripting

Replace the content of file with incremented value

I have a file myfile with only one value 1000.I am using it in a shell script.Each time i run the script,the file shud get incremented by 1. I have used the below code for incrementing the value- curr=`cat myfile` echo $curr curr=`expr $curr + 1` But i am not sure how to save this replaced... (2 Replies)
Discussion started by: saga20
2 Replies

7. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

8. Shell Programming and Scripting

Replace file name with Space as content

Hi, I am having a files in my directory like this: 2014 1049_file1.txt 2014 1050_file2.txt 2014 1110_file3.txt 2014 1145_file4.txt 2014 2049_file5.txt I need to replace the above file names like this without changing the content of filename: file1.txt file2.txt file3.txt... (10 Replies)
Discussion started by: rohit_shinez
10 Replies

9. Shell Programming and Scripting

Content of filtered files write as columns into one file

Hi everybody! i have a lot of files where i filter out data. #!/bin/bash f=sample_*.Spe for i in $f `eval echo ls sample_*.Spe` do if test -f "$i" then awk 'FNR==8 ||FNR==10 || (FNR>=13 && FNR<=268) {print $1}' $i > test$i.txt paste test$i.txt test_f.txt > test_f.txt ... (5 Replies)
Discussion started by: IMPe
5 Replies

10. Shell Programming and Scripting

Replace content from a file and save

Hi, Right now there is a file called 'qm.ini' which is owned by mqm:mqm and I am trying to replace a line from this file with something else and save. I am using the below perl command to replace and save within a shell script with a different user called 'mqadm' which is also part of mqm... (1 Reply)
Discussion started by: bdpl
1 Replies
FBB::OFoldStream(3bobcat)					  Fold long lines					 FBB::OFoldStream(3bobcat)

NAME
FBB::OFoldStream - Folds long lines SYNOPSIS
#include <bobcat/ofoldstream> Linking option: -lbobcat DESCRIPTION
FBB::OFoldStream folds long lines written to it. The OFoldStream writes the (folded) lines to a second ostream which is either used by or opened by the OFoldStream object. OFoldStream objects never fold lines in the middle of series of non-blank characters but will always break a line at white space charac- ters. The resulting lines will always appear to the right of a configurable left margin and to the left of a configurable right margin. There is a somewhat pathological exception to this: if a word is too long to fit in between the margins then the word will exceed the right hand margin. The indentation used for the left margins is configurable to either blanks (the default) or tabs. When tabs are used the width of a tab character is configurable, using a default of 8 positions in the destination stream. OFoldStream is implemented as a wrapper class around std::ostream and FBB::OFoldStreambuf and a more complete description of the folding process can be found in the ofoldstreambuf(3bobcat) man page. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
std::ostream, (and privately from FBB::OFoldStreambuf) ENUMERATION
The enumeration TabsOrBlanks is used to select tabs or blanks when writing the indentation. The default is blanks. When tabs are selected the display width of tabs characters can be configured as well (using the default of 8 positions for each tab-character. The enumeration has two values: o BLANKS: The default, indicating that the left margin is specified and written as a number of blanks; o TABS: Indicating that the left margin is specified and written as a number of tab-characters. The enumeration TrailingBlanks is used to configure the OFoldStream object with respect to any trailing blanks that may appear on the final line. It is the same enumeration type as used with OFoldStreambuf (cf. ofoldstreambuf(3bobcat)) having two values: o IGNORE_TRAILING_BLANKS: This indicates that trailing blanks appearing at the final line if it is not terminated by a newline should not be written to the destination std::ostream. This is the default used by OFoldStream objects. o KEEP_TRAILING_BLANKS: This indicates that trailing blanks at the final line if it is not terminated by a newline should be written to the destination std::ostream CONSTRUCTORS
o OFoldStream(): This constructor initializes an OFoldStream object but does not associate it with a destination stream. It uses the values 0, 80, BLANKS, and IGNORE_TRAILING_BLANKSfor, resp. its left margin, right margin left-margin characters and TrailingBlanks handling mode. o OFoldStream(char const *fname, size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAILING_BLANKS): This constructor initializes an OFoldStream object and opens (using std::ios::out) the destination stream using the name specified as its fname argument. o OFoldStream(std::ostream &stream, size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAILING_BLANKS): This constructor initializes an OFoldStream object and uses as its destination stream the std::ostream stream. The destructor writes any buffered information to the destination stream and will then flush the destination stream. MEMBER FUNCTIONS
All members of std::ostream are available, as FBB::OFoldStream inherits from this class. o void close(): This member flushes any pending information to the destination stream and then closes the destination stream. o void open(char const *fname, openmode mode = std::ios::out): This member associates the OFilterStream object with an std::ofstream object whose filename is provided and that should receive the folded information. o void open(std::ostream &out): This member associates the OFilterStream object with the provided ostream object. o void setMargins(size_t leftMargin, size_t rightMargin): This member can be used to modify the left- and right folding margins. Note that the left margin may also be modified using the FBB::lm and FBB::mlm manipulators. o void setTrailingBlanks(TrailingBlanks tb): This member can be used to modify the currently used TrailingBlanks parameter. o void useBlanks(): This member can be used to select blanks to be used when inserting left margins. o void useTabs(size_t tabWidth = 8): This member can be used to select tab-characters to be used when inserting left margins. The second parameter is used to specify the display width of a tab-character. STATIC MEMBER FUNCTIONS
o size_t leftMargin(std::ostream const &os): This member returns the current left margin setting of the OFoldStream object passed to it as its argument. The member defines a std::ostream parameter since in many cases the OFoldStream object will be used in functions themselves defining std::ostream parame- ters. Internally, the std::ostream's std::streambuf is down cast to an OFoldStreambuf and an FBB::Errno exception is thrown if that cast fails. o size_t rightMargin(std::ostream const &os): This member returns the current right margin setting of the OFoldStream object passed to it as its argument. The member's parameter is down cast in the same way as leftMargin()'s argument: an FBB::Errno exception is thrown if that cast fails. EXAMPLE
#include <iostream> #include <string> #include <bobcat/ofoldstream> using namespace std; using namespace FBB; void margins(ostream &out) { cout << OFoldStream::leftMargin(out) << ", " << OFoldStream::rightMargin(out) << endl; } int main() { OFoldStream out(cout, 4, 40); out << lm(4); string line; while (getline(cin, line)) out << line << ' '; margins(out); return 0; } FILES
bobcat/ofoldstream - defines the class interface SEE ALSO
bobcat(7), lm(3bobcat), mlm(3bobcat), ofoldstreambuf(3bobcat) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::OFoldStream(3bobcat)
All times are GMT -4. The time now is 03:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy