Sponsored Content
Top Forums Shell Programming and Scripting search pattern and replace x-y characters in nth line after every match Post 302537268 by anilvk on Thursday 7th of July 2011 01:49:54 PM
Old 07-07-2011
search pattern and replace x-y characters in nth line after every match

Hi,

I am looking for any script which can do the following.
have to read a pattern from fileA and copy it to fileB.


fileA:
...
...
Header
...
...
..p1
...
...

fileB:
....
....
Header
...
...
..p2
....
...

The position of "p1" is fixed relative to "Header"
say x th charecter in nth line after Header.
"p1" size is also fixed 5 chars if it helps.

p2 is location and size are same as p1
i have to read "p1" from fileA and replace "p2" in fileB with "p1"

How can we do this ??

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - Replace Line which contains the Pattern match with a new line

I need to replace the line containing "STAGE_DB" with the line "STAGE_DB $DB # database that contains the table being loaded ($workingDB)" Here $DB is passed during the runtime. How can I do this? Thanks, Kousikan (2 Replies)
Discussion started by: kousikan
2 Replies

2. Shell Programming and Scripting

Search word in a line and print earlier pattern match

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Search for: word1.word2 (Which procedure contain this word, I need procedure name in output. Expected output: procedure test1 procedure test2 procedure test3 procedure test4 ... (7 Replies)
Discussion started by: susau_79
7 Replies

3. Shell Programming and Scripting

Getting filename for Nth line pattern match

Hi, I have many scripts in particular directory. And few of the scripts have exit 0 in second line. Now i wanted to list out the scripts name which has the exit 0 in its second line I tried many options , but i can not get the filename along with the nth line pattern match :mad:. Can anyone... (14 Replies)
Discussion started by: puni
14 Replies

4. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies

5. Shell Programming and Scripting

Help with replace line based on specific pattern match

Input file data20714 7327 7366 detail data20714 7327 7366 main data250821 56532 57634 detail data250821 57527 57634 main data250821 57359 57474 main data250821 57212 57301 main data250821 57140 57159 detail data250821 56834 57082 main data250821 56708 56779 main ... (3 Replies)
Discussion started by: perl_beginner
3 Replies

6. UNIX for Dummies Questions & Answers

Printing nth and n+1th line after a pattern match

Hi , I want to print the nth and n+1 lines from a file once it gets a pattern match. For eg: aaa bbb ccc ddd gh jjjj If I find a match for bbb then I need to print bbb as well as 3rd and 4th line from the match.. Please help..Is it possible to get a command using sed :) (6 Replies)
Discussion started by: saj
6 Replies

7. Shell Programming and Scripting

I need to know how to replace a line after a pattern match with an empty line using SED

Hi How Are you? I am doing fine! I need to go now? I will see you tomorrow! Basically I need to replace the entire line containing "doing" with a blank line: I need to the following output: Hi How Are you? I need to go now? I will see you tomorrow! Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies

8. Shell Programming and Scripting

awk to search for specific line and replace nth column

I need to be able to search for a string in the first column and if that string exists than replace the nth column with "-9.99". AW12000012012 2.38 1.51 3.01 1.66 0.90 0.91 1.22 0.82 0.57 1.67 2.31 3.63 0.00 AW12000012013 1.52 0.90 1.20 1.34 1.21 0.67 ... (14 Replies)
Discussion started by: ncwxpanther
14 Replies

9. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

10. Shell Programming and Scripting

How to display when nth line match a pattern?

Hi All, I have sample of listing as following Database 2 entry: Database alias = PXRES Database name = PXRES Local database directory = /db2/data1/db2phnx Database release level = d.00 Comment ... (3 Replies)
Discussion started by: ckwan
3 Replies
Astro::FITS::Header::CFITSIO(3pm)			User Contributed Perl Documentation			 Astro::FITS::Header::CFITSIO(3pm)

NAME
Astro::FITS::Header::CFITSIO - Manipulates FITS headers from a FITS file SYNOPSIS
use Astro::FITS::Header::CFITSIO; $header = new Astro::FITS::Header::CFITSIO( Cards => @array ); $header = new Astro::FITS::Header::CFITSIO( File => $file ); $header = new Astro::FITS::Header::CFITSIO( fitsID => $ifits ); $header->writehdr( File => $file ); $header->writehdr( fitsID => $ifits ); DESCRIPTION
This module makes use of the CFITSIO module to read and write directly to a FITS HDU. It stores information about a FITS header block in an object. Takes an hash as an argument, with either an array reference pointing to an array of FITS header cards, or a filename, or (alternatively) and FITS identifier. REVISION
$Id$ METHODS
configure Reads a FITS header from a FITS HDU $header->configure( Cards => @cards ); $header->configure( fitsID => $ifits ); $header->configure( File => $file ); $header->configure( File => $file, ReadOnly => $bool ); Accepts an FITS identifier or a filename. If both fitsID and File keys exist, fitsID key takes priority. If "File" is specified, the file is normally opened in ReadWrite mode. The "ReadOnly" argument takes a boolean value which determines whether the file is opened ReadOnly. writehdr Write a FITS header to a FITS file $header->writehdr( File => $file ); $header->writehdr( fitsID => $ifits ); Its accepts a FITS identifier or a filename. If both fitsID and File keys exist, fitsID key takes priority. Returns undef on error, true if the header was written successfully. NOTES
This module requires Pete Ratzlaff's Astro::FITS::CFITSIO module, and William Pence's "cfitsio" subroutine library (v2.1 or greater). SEE ALSO
Astro::FITS::Header, Astro::FITS::Header::Item, Astro::FITS::Header::NDF, Astro::FITS::CFITSIO AUTHORS
Alasdair Allan <aa@astro.ex.ac.uk>, Jim Lewis <jrl@ast.cam.ac.uk>, Diab Jerius. COPYRIGHT
Copyright (C) 2007-2009 Science & Technology Facilities Council. Copyright (C) 2001-2006 Particle Physics and Astronomy Research Council. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,Suite 330, Boston, MA 02111-1307, USA perl v5.14.2 2012-06-30 Astro::FITS::Header::CFITSIO(3pm)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy