Sponsored Content
Top Forums Shell Programming and Scripting Shell Script to find common lines and replace next line Post 302887942 by madira on Tuesday 11th of February 2014 08:35:55 PM
Old 02-11-2014
That would work fine ,if file1 content and file2 contents are different... but it is not working if contents are same only ^msgstr.*$ line is different.. for example..it wont work if my contents are something like this:

file1:
Code:
         hgacdavd
sndm,ACNMSDC
msgid "Rome"
msgstr ""
kgcksdcgfkdsb
msgid ""
hsdvchgsdvc
msgstr ""
dhshfjksdfhmd
msgid "Vidya"
msgstr ""
sdjhcbnd
dcndnv
cfnkdndvrknvkf
dfkvrnkdfnk
snfvrkng
msgid "Rome"
msgstr ""
wdbhkjbcfj
#dmcdmf
f,nvdf,

fvnfnvk
vfmf,mv
vfn

msgid "vid"
msgstr ""
dmcbdmbcvmfbvmkhsdk

file2:
Code:
         hgacdavd
sndm,ACNMSDC
msgid "Rome"
msgstr "new bie"
sdbsjbcdcbwoido
kgcksdcgfkdsb
msgid ""
hsdvchgsdvc
msgstr ""
dhshfjksdfhmd
msgid "vidya"
msgstr "expert"
sdjhcbnd
dcndnv
cfnkdndvrknvkf
dfkvrnkdfnk
snfvrkng
msgid "Rome"
msgstr "new bie"
sdbsjbcdcbwoido
wdbhkjbcfj
#dmcdmf
f,nvdf,

fvnfnvk
dvnjfkdvhnkfvnknsbdjh


msgid "vid"
msgstr "newton"
dfenfjdbrfjbvlfnvl
dmcbdmbcvmfbvmkhsdk

after execution , file1 content should be:
Code:
  hgacdavd
sndm,ACNMSDC
msgid "Rome"
msgstr "new bie"
kgcksdcgfkdsb
msgid ""
hsdvchgsdvc
msgstr ""
dhshfjksdfhmd
msgid "Vidya"
msgstr "expert"
sdjhcbnd
dcndnv
cfnkdndvrknvkf
dfkvrnkdfnk
snfvrkng
msgid "Rome"
msgstr "new bie"
wdbhkjbcfj
#dmcdmf
f,nvdf,

fvnfnvk
vfmf,mv
vfn

msgid "vid"
msgstr "newton"
dmcbdmbcvmfbvmkhsdk

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

find a shell and replace the line

I need a shell which makes a search of an UNIX script and them modifies. :confused: vi $(grep -l 5 $(find . -name 'vellon.bcf' -print)) (1 Reply)
Discussion started by: jvellon
1 Replies

2. Shell Programming and Scripting

To find all common lines from 'n' no. of files

Hi, I have one situation. I have some 6-7 no. of files in one directory & I have to extract all the lines which exist in all these files. means I need to extract all common lines from all these files & put them in a separate file. Please help. I know it could be done with the help of... (11 Replies)
Discussion started by: The Observer
11 Replies

3. Shell Programming and Scripting

shell script to find and replace a line using a identifier

Hi all im having trouble starting with a shell script, i hope someone here can help me i have 2 files file1: 404905.jpg 516167 404906.jpg 516168 404917.psd 516183 404947.pdf 516250 file2: 516250 /tmp/RecyclePoster18241.pdf 516167 /tmp/ReunionCardFINAL.jpg 516168... (7 Replies)
Discussion started by: kenray
7 Replies

4. Shell Programming and Scripting

Find 5 lines and replace with 18 line in sql file where it contains multiple blocks.

My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block rem Subset Rows (&&tempName.*) CREATE VIEW &&tempName.* AS SELECT * FROM &&tempName.* WHERE f is not null and replace with following code rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies

5. Shell Programming and Scripting

script to replace numbers on lines according to condition on the same line

hello everyone my file contains many records, the following is a sample: BEGIN ASX1500000050002010120000000308450201012000177 ASX1100002000000201012000000038450201012000220 ASX1600100005000201012000000038450020101200177 ASX1900100006000201067000000058450020101200177... (2 Replies)
Discussion started by: neemoze
2 Replies

6. Shell Programming and Scripting

Find common lines between multiple files

Hello everyone A few years Ago the user radoulov posted a fancy solution for a problem, which was about finding common lines (gene variation names) between multiple samples (files). The code was: awk 'END { for (R in rec) { n = split(rec, t, "/") if (n > 1) dup = dup ?... (5 Replies)
Discussion started by: bibb
5 Replies

7. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

8. Shell Programming and Scripting

Find common lines with one file and with all of the files in another folder

Hi! I would like to comm -12 with one file and with all of the files in another folder that has a 100 files or more (that file is not in that folder) to find common text lines. I would like to have each case that they have common lines to be written to a different output file and the names of the... (6 Replies)
Discussion started by: Eve
6 Replies

9. Shell Programming and Scripting

Find common lines between all of the files in one folder

Could it be possible to find common lines between all of the files in one folder? Just like comm -12 . So all of the files two at a time. I would like all of the outcomes to be written to a different files, and the file names could be simply numbers - 1 , 2 , 3 etc. All of the file names contain... (19 Replies)
Discussion started by: Eve
19 Replies

10. Shell Programming and Scripting

Script using awk to find and replace a line, how to ignore comment lines

Hello, I have some code that works more or less. This is called by a make file to adjust some hard-coded definitions in the src code. The script generated some values by looking at some of the src files and then writes those values to specific locations in other files. The awk code is used to... (3 Replies)
Discussion started by: LMHmedchem
3 Replies
Alien::Package::Rpm(3pm)				User Contributed Perl Documentation				  Alien::Package::Rpm(3pm)

NAME
Alien::Package::Rpm - an object that represents a rpm package DESCRIPTION
This is an object class that represents a rpm package. It is derived from Alien::Package. FIELDS
prefixes Relocatable rpm packages have a prefixes field. METHODS
checkfile Detect rpm files by their extention. install Install a rpm. If RPMINSTALLOPT is set in the environement, the options in it are passed to rpm on its command line. scan Implement the scan method to read a rpm file. unpack Implement the unpack method to unpack a rpm file. This is a little nasty because it has to handle relocatable rpms and has to do a bit of permissions fixing as well. prep Prepare for package building by generating the spec file. cleantree Delete the spec file. build Build a rpm. If RPMBUILDOPT is set in the environement, the options in it are passed to rpm on its command line. An optional parameter, if passed, can be used to specify the program to use to build the rpm. It defaults to rpmbuild. version Set/get version. When retreiving the version, remove any dashes in it. postinst postrm preinst prerm Set/get script fields. When retrieving a value, we have to do some truely sick mangling. Since debian/slackware scripts can be anything -- perl programs or binary files -- and rpm is limited to only shell scripts, we need to encode the files and add a scrap of shell script to make it unextract and run on the fly. When setting a value, we do some mangling too. Rpm maintainer scripts are typically shell scripts, but often lack the leading shebang line. This can confuse dpkg, so add the shebang if it looks like there is no shebang magic already in place. Additionally, it's not uncommon for rpm maintainer scripts to contain bashisms, which can be triggered when they are ran on systems where /bin/sh is not bash. To work around this, the shebang line of the scripts is changed to use bash. Also, if the rpm is relocatable, the script could refer to RPM_INSTALL_PREFIX, which is set by rpm at run time. Deal with this by adding code to the script to set RPM_INSTALL_PREFIX. arch Set/get arch field. When the arch field is set, some sanitizing is done first to convert it to the debian format used internally. When it's retreived it's converted back to rpm form from the internal form. AUTHOR
Joey Hess <joey@kitenet.net> perl v5.14.2 2011-08-05 Alien::Package::Rpm(3pm)
All times are GMT -4. The time now is 05:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy