Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Append a string on the next line after a pattern string is found Post 302579723 by newbeee on Tuesday 6th of December 2011 11:41:59 AM
Old 12-06-2011
Append a string on the next line after a pattern string is found

Right now, my code is:
Code:
s/Secondary Ins./Secondary Ins.\
1/g

It's adding a 1 as soon as it finds Secondary Ins.
Primary Ins.: MEDICARE B DMERC Secondary Ins.
1: CONTINENTAL LIFE INS

What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It should look something like this:

Primary Ins.: MEDICARE B DMERC Secondary Ins.: CONTINENTAL LIFE INS
1

Help Please!

Last edited by vbe; 12-06-2011 at 01:11 PM.. Reason: code tags next time!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to append a string to next line in perl

hi all , i have a requirement like this.. this just a sample script... $ cat test.sh #!/bin/bash perl -e ' open(IN,"addrss"); open(out,">>addrss"); @newval; while (<IN>) { @col_val=split(/:/); if ($.==1) { for($i=0;$i<=$#col_val;$i++) { ... (2 Replies)
Discussion started by: tprayush
2 Replies

2. Shell Programming and Scripting

Append string to first line of a file

Hi, Please suggest me to write unix command, HEADER20110101 string append to first line of a file.. Regards Akshu (3 Replies)
Discussion started by: akshu.agni
3 Replies

3. Shell Programming and Scripting

grep on string and printing line after until another string has been found

Hello Everyone, I just started scripting this week. I have no background in programming or scripting. I'm working on a script to grep for a variable in a log file Heres what the log file looks like. The x's are all random clutter xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Discussion started by: rxc23816
7 Replies

4. Shell Programming and Scripting

Grep a string and write a value to next line of found string

Hi, I have two variables x and y. i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name. basically it is like as below wf_xxxxxx $$a= $$b= $$c= figo $$d=bentley i need to grep the 'wf_xxxx' and then... (6 Replies)
Discussion started by: angel12345
6 Replies

5. Shell Programming and Scripting

Append next line to previous line when one pattern not found

Hi, I need help for below scenario.I have a flat file which is having records seperated by delimiters which will represent each record for oracle table.My Control file will consider each line as one record for that table. Some of the lines are aligned in two/three lines so that records are... (4 Replies)
Discussion started by: kannansr621
4 Replies

6. Shell Programming and Scripting

remove anything after repeated string pattern found

HI, Can anyone help me with a script. i/p calc 1 2 3 4 5 6 7 8 calc 4 5 6 calc 7 8 9 o/p calc 1 2 3 4 5 6 7 8 calc 4 5 6 i.e remove anything after where two times the string calc is found. thanks (3 Replies)
Discussion started by: Indra2011
3 Replies

7. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

8. Shell Programming and Scripting

bash: need to have egrep to return a text string if the search pattern has NOT been found

Hello all, after spending hours of searching the web I decided to create an account here. This is my first post and I hope one of the experts can help. I need to resolve a grep / sed / xargs / awk problem. My input file is just like this: ----------------------------------... (6 Replies)
Discussion started by: bash4ever
6 Replies

9. Shell Programming and Scripting

Append this string to end of each line

Platform: Solaris 10 I have a file like below $ cat languages.txt Spanish Norwegian English Persian German Portugese Chinese Korean Hindi Malayalam Bengali Italian Greek Arabic I want to append the string " is a great language" at end of each line in this file. (3 Replies)
Discussion started by: omega3
3 Replies

10. Shell Programming and Scripting

Append text on particular line after pattern found

hi, i have /etc/inittab, I want to add another line after that when i find a pattern "l6:6:wait:/etc/rc.d/rc 6". original l6:6:wait:/etc/rc.d/rc 6 after-change l6:6:wait:/etc/rc.d/rc 6 /sbin/if-pp-to-cng (3 Replies)
Discussion started by: learnbash
3 Replies
gdcmimg(1)							       GDCM								gdcmimg(1)

NAME
gdcmimg - Manipulate DICOM image file. SYNOPSIS
gdcmimg [options] file-in file-out DESCRIPTION
The gdcmimg command line tool can be used in two fashions: o 1. Converting a recognized file format into its encapsulated DICOM counterpart, o 2. Anonymizing a rectangular portion of a DICOM file. PARAMETERS
file-in input filename file-out output filename options PARAMETERS -i --input Input filename -o --output Output filename options --endian %s Endianness (LSB/MSB). -d --depth %d Depth (8/16/32). --sign %s Pixel sign (0/1). -s --size %d,%d Size. -C --sop-class-uid SOP Class UID (name or value). -T --study-uid Study UID. -S --series-uid Series UID. --root-uid Root UID. fill options -R --region %d,%d Region. -F --fill %d Fill with pixel value specified. general options -h --help print this help text and exit -v --version print version information and exit -V --verbose verbose mode (warning+error). -W --warning warning mode, print warning information -E --error error mode, print error information -D --debug debug mode, print debug information environment variable GDCM_ROOT_UID Root UID Supported File Format (appropriate file extension) gdcmimg will base it's conversion process based on the file extension. Follows the list of recognized file extension. When no extension is found, DICOM file is assumed. input format * RAW (raw, gray, rgb) * RLE (rle) * PNM (pgm, pnm, ppm) * JPEG-LS (jls) * JPEG 2000 (jp2, j2k, j2c, jpc) * JPEG (jpg, jpeg, ljpg, ljpeg) * DICOM () output format: * PGM (pgm, pnm, ppm) * DICOM () For RAW file format, you should take special care of the --endian option. For the (old) JPEG file format, both the lossy and lossless format are supported, user should pay attention to the --sign option. For file format such as RLE or RAW, user is expected to fill in information required to find the dimension and type of input data as there is no other way to find this information. For all other file format, the properties are derived from the file format itself. PNM file are supposed to be big endian. Typical usage Remove a rectangular part of the image To fill the region [0,100]x[0,100] of a DICOM image simply do: $ gdcmimg --fill 0 --region 0,100,0,100 -i input.dcm -o output_black.dcm Warning: if the Pixel Data is compressed, the image is first decompressed so that pixel can be set to 0, but it is not recompressed. Convert RAW to DICOM Recognized extension is .raw, .gray or .rgb (case insensitive) $ gdcmimg --size 512,512 --depth 16 -i input.raw -o output.dcm the image will be a Secondary Capture When the input is 3 component, one need to specify explicitely the Samples Per Pixel: $ gdcmimg --size 512,512 --spp 3 input_rgb.raw output_rgb.dcm When the filename contains .rgb as file extension output is automatically recognized as RGB no need to specify --spp $ gdcmimg --size 512,512 input.rgb output_rgb.dcm You can use the dd cmd line to skip any header you would like to discard, for instance, if you would like to skip the first 108 bytes, simply do: $ dd skip=108 bs=1 if=input.raw of=output.raw Convert PGM/PNM/PPM to DICOM Recognized extensions are .pgm, .pnm, .ppm (case insensitive) $ gdcmimg -i input.pgm -o output.dcm the image will be a Secondary Capture Convert RLE to DICOM Recognized extension is .rle (case insensitive) $ gdcmimg --size 512,512 --depth 16 -i input.rle -o output.dcm the image will be a Secondary Capture Convert JPEG to DICOM Recognized extensions are .jpg, .jpeg, .ljpg, .ljpeg (case insensitive) $ gdcmimg -i input.ljpeg -o output.dcm the image will be a Secondary Capture Convert J2K to DICOM Recognized extensions are .j2k, .jp2, .jpc (case insensitive) $ gdcmimg -i input.j2k -o output.dcm the image will be a Secondary Capture Specifying a SOP Class UID Instead of the default Secondary Capture Image Storage, one may want to specify, say VL Photographic Image Storage. $ gdcmimg --sop-class-uid 1.2.840.10008.5.1.4.1.1.77.1.4 input.jpg output.dcm Multiple Files gdcmimg handle nicely a set of files (for instance jpeg): $ gdcmimg 1.jpg 2.jpg 3.jpg 4.jpg output.dcm Warning There are a couple of issues with gdcmimg implementation: For JFIF file and JP2 file (with header) the header is copied into the Pixel Data element which is illegal for JP2. Use gdcmconv to properly re-encode a JP2/JFIF file into J2K/JPG. $ gdcmimg input.jp2 output_jp2.dcm $ gdcmconv --j2k --force output_jp2.dcm output_j2k.dcm For RLE file, no check is done for crossing the row boundary. It is recommended to use gdcmconv --rle to re-encode into a proper RLE file in case of doubt. Of course if the compression is not ok with your setup, you can always de-encapsulated the DICOM file (typically JPEG) to a non- encapsulated form, using gdcmconv: $ gdcmconv --raw input_jpeg.dcm output_raw.dcm SEE ALSO
gdcmdump(1), gdcmdump(1), gdcmraw(1), convert(1), dd(1) COPYRIGHT
Copyright (c) 2006-2011 Mathieu Malaterre Version 2.2.0 Tue Feb 5 2013 gdcmimg(1)
All times are GMT -4. The time now is 08:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy