Sponsored Content
Top Forums Shell Programming and Scripting Delete one Line from Main File and Create another Post 302411210 by kapilk on Thursday 8th of April 2010 02:02:10 AM
Old 04-08-2010
Delete one Line from Main File and Create another

Hi

I need to write a script which will search for some text in some CSV files and will delete the record/line with the matching text and will insert that record/line into some other file.

Can you please help?

Here is what I want: -

Contents of MainFile.csv: -

1,2,3,Loan,4,5,6
1,2,3,Loan,4,5,6
1,2,3,Bank,4,5,6
1,2,3,Bank,4,5,6
1,2,3,Cheque,4,5,6
1,2,3,Cheque,4,5,6

I wish to search the current directory and file out which all files contain the text "Cheque" and I wish to delete these records from all the files and thus MainFile.csv will become

Contents of MainFile.csv: -

1,2,3,Loan,4,5,6
1,2,3,Loan,4,5,6
1,2,3,Bank,4,5,6
1,2,3,Bank,4,5,6

and another file should be created TEMP.CSV with following contents: -

1,2,3,Cheque,4,5,6
1,2,3,Cheque,4,5,6

Can you please help me how to do this?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to delete line from a file

Hi , I have a file it content is like that /vol.nas/u08/aip_triage/hany/Tesko/:CC::RPAS /home/biblawh/myscript:CC::RPAS i need to search for a certain pattern inside that file and delete the line if i find this pattern without redirecting the output into another file . so i used the... (0 Replies)
Discussion started by: ramezernest
0 Replies

2. Shell Programming and Scripting

Can I create a file from the command line

I want to create a file explicitly from the command line without going in to the file directly just create it. Can I do that? Thanks in advance. (5 Replies)
Discussion started by: airon23bball
5 Replies

3. Shell Programming and Scripting

read line by line and create new file

I would like to read line by line out of a file (one word per line) and create with each line a file. The read line should be also pasted into the file with some other text. Something like this: cat readfile.txt | mkfile readline << "bla bli $readline blu" (7 Replies)
Discussion started by: borobudur
7 Replies

4. Shell Programming and Scripting

Delete first line from file and more....

Hello, I have to deal with several files that will be named something like this: E00001.TXT, E00002.TXT etc. Each file will have a alpha character on the first position of the first line which I want to place in a variable, then delete the entire line leaving the remainder of text. This new file... (6 Replies)
Discussion started by: dfb500
6 Replies

5. Shell Programming and Scripting

create dir in main &subdirs,perform action

Hi, I have one dir which has N subdirs.For ex: /home/user/Project_Src /home/user/Project_Src/Dir_A /home/user/Project_Src/Dir_A/subdir/sub_dir2 /home/user/Project_Src/Dir_A/subdir/sub_dir3 /home/user/Project_Src/Dir_B /home/user/Project_Src/Dir_B/Build i want to create a folder with... (2 Replies)
Discussion started by: dragon.1431
2 Replies

6. Shell Programming and Scripting

Delete a particular line from a file

I have a file of following form 2886758410 2886758500 17 1999-Mar-18 16:26:26 1 0 52 139 1129 2886758420 2886758500 17 1999-Mar-18 16:26:35 1 0 52 139 1131 2886758420 2886758500 17 1999-Mar-18 16:26:41 0 0 56 56 1132... (4 Replies)
Discussion started by: vaibhavkorde
4 Replies

7. Shell Programming and Scripting

create txt file form data file and add some line on it

Hi Guys, I have file A.txt File A Data AK1521 AK2536 AK3164 I want create text file of all data above and write some data on each file. want Output on below folder /home/kka/out AK1521.txt Hi Welocme (3 Replies)
Discussion started by: asavaliya
3 Replies

8. AIX

[Solved] Not able to delete/create file in /tmp

This is AIX box and I am not able to create or delete file in /tmp though space is there root@ttcols01/ #touch /tmp/test_file touch: 0652-046 Cannot create /tmp/test_file. root@ttcols01/ #mkdir /tmp/test_dir mkdir: 0653-358 Cannot create /tmp/test_dir. /tmp/test_dir: Invalid file system... (9 Replies)
Discussion started by: solaris_1977
9 Replies

9. UNIX for Dummies Questions & Answers

How to create a file even root user also cant delete?

Is there any way to create a file in linux that root user also can't delete? (8 Replies)
Discussion started by: palani13dec
8 Replies

10. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies
SVN::Dump::Record(3)					User Contributed Perl Documentation				      SVN::Dump::Record(3)

NAME
SVN::Dump::Record - A SVN dump record SYNOPSIS
# SVN::Dump::Record objects are returns by the next_record() # method of SVN::Dump DESCRIPTION
An "SVN::Dump::Record" object represents a Subversion dump record. METHODS
"SVN::Dump" provides the following gourps of methods: Record methods new() Create a new empty "SVN::Dump::Record" object. type() Return the record type, as guessed from its headers. The method dies if the record type cannot be determined. set_header( $h, $v ) Set the header $h to the value $v. get_header( $h ) Get the value of header $h. set_property( $p, $v ) Set the property $p to the value $v. get_property( $p ) Get the value of property $p. delete_property( @k ) Delete the set_text( $t ) Set the value of the text block. get_text() Get the value of the text block. Inner blocks manipulation A "SVN::Dump::Record" is composed of several inner blocks of various kinds: "SVN::Dump::Headers", "SVN::Dump::Property" and "SVN::Dump::Text". The following methods provide access to these blocks: set_headers_block( $headers ) get_headers_block() Get or set the "SVN::Dump::Headers" object that represents the record headers. set_property_block( $property ) get_property_block() Get or set the "SVN::Dump::Property" object that represents the record property block. delete_property( @keys ) Delete the given properties. Behave like the builtin "delete()". set_text_block( $text ) get_text_block() Get or set the "SVN::Dump::Text" object that represents the record text block. set_included_record( $record ) get_included_record() Some special record are actually output recursiveley by svnadmin dump. The "record in the record" is stored within the parent record, so they are parsed as a single record with an included record. "get_record()" / "set_record()" give access to the included record. According to the Subversion sources (subversion/libsvn_repos/dump.c), this is a "delete original, then add-with-history" node. The dump looks like this: Node-path: tags/mytag/myfile Node-kind: file Node-action: delete Node-path: tags/mytag/myfile Node-kind: file Node-action: add Node-copyfrom-rev: 23 Node-copyfrom-path: trunk/myfile Note that there is a single blank line after the first header block, and four after the included one. update_headers() Update the various "...-length" headers. Used internally. You must call this method if you update the inner property or text blocks directly, or the results of "as_string()" will be inconsistent. Information methods has_prop() Return a boolean value indicating if the record has a property block. has_text() Return a boolean value indicating if the record has a text block. has_prop_only() Return a boolean value indicating if the record has only a property block (and no text block). has_prop_or_text() Return a boolean value indicating if the record has a property block or a text block. property_length() Return the length of the property block. text_length() Return the length of the text block. Output method as_string() Return a string representation of the record. Warning: dumping a record currenly gives back the information that was read from the original dump. Which means that if you modified the property or text block of a record, the headers will be inconstent. ENCAPSULATION
When using "SVN::Dump" to manipulate a SVN dump, one should not directly access the "SVN::Dump::Headers", "SVN::Dump::Property" and "SVN::Dump::Text" components of a "SVN::Dump::Record" object, but use the appropriate "set_...()" and "get_...()" methods of the record object. These methods compute the appropriate modifications of the header values, so that the "as_string()" method outputs the correct information after any modification of the record. SEE ALSO
"SVN::Dump::Headers", "SVN::Dump::Property", "SVN::Dump::Text". COPYRIGHT &; LICENSE Copyright 2006 Philippe 'BooK' Bruhat, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-06-12 SVN::Dump::Record(3)
All times are GMT -4. The time now is 05:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy