Sponsored Content
Top Forums Shell Programming and Scripting sed or awk command to replace a string pattern with another string based on position of this string Post 302655995 by cabrao on Thursday 14th of June 2012 06:07:54 AM
Old 06-14-2012
I'm not sure if I understood your problem, but is it this what you're looking for?

Code:
awk -F, -vQ="'" '/^INSERT INTO/&&$8=$13=$18=Q"0000-0000 00:00:00"Q' OFS=, file


Last edited by cabrao; 06-14-2012 at 07:13 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the position of a string and replace with another string

Hi, I have a file named "Test_2008_01_21" The file contains a string "manual" that occurs many times in the file How can i find the positions of the string "manual" in the file Ex: if the string " manual " occurs three times in the file. i want to replace the second occurance of string... (6 Replies)
Discussion started by: bab123
6 Replies

2. Shell Programming and Scripting

Search for a string and replace the searched string in the same position

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found..The issue is the last... (15 Replies)
Discussion started by: ganesh_248
15 Replies

3. UNIX for Dummies Questions & Answers

Search for a string and replace the searched string in the same position in samefile

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Discussion started by: ganesh_248
27 Replies

4. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

5. UNIX for Dummies Questions & Answers

Search a string in the file and then replace another string after that position

Hi I am looking for a particular string in a file.If the string exists, then I want to replace another string with some other text.Once replaced, search for the same text after that character position in the file. :wall: E.g: Actual File content: Hello Name: Nitin Raj Welcome to Unix... (4 Replies)
Discussion started by: dashing201
4 Replies

6. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

7. Shell Programming and Scripting

Using sed to replace a string in a specific position

I asked this before, but my problem got more complicated. Heres what I am trying to do: I'm trying to replace a string at a certain location with another string. Heres the file I'm trying to change: \E I want to replace the escape code at the 3rd line, 2nd column with this escape code... (3 Replies)
Discussion started by: tinman47
3 Replies

8. Shell Programming and Scripting

Search for a string at a particular position and replace with blank based on position

Hi, I have a file with multiple lines(fixed width dat file). I want to search for '02' in the positions 45-46 and if available, in that lines, I need to replace value in position 359 with blank. As I am new to unix, I am not able to figure out how to do this. Can you please help me to achieve... (9 Replies)
Discussion started by: Pradhikshan
9 Replies

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
OUTPUT(5)							File Formats Manual							 OUTPUT(5)

NAME
output - output data file formats DESCRIPTION
This manual page describes the output formats of the files created by the Yagi-Uda project's output program. The files are ASCII file, so can be analysed with any graph plotting program. Example of a .dat File Below is a typical .dat file, for a 4ele 144-146MHz beam, optimised for a huge (and useless) FB. # Driven=1 parasitic=3 total-elements=4 design=145.000MHz # Checked from 144.000MHz to 146.000MHz. f(MHz) E(deg) H(deg) R jX VSWR Gain(dBi) FB(dB) SideLobes(dB) 144.000 54.7 71.5 44.47 -2.35 1.136 9.386 21.944 16.650 144.500 54.0 70.1 41.34 -0.75 1.210 9.553 27.244 17.153 145.000 53.2 68.4 37.55 1.61 1.335 9.742 103.055 17.777 145.500 52.3 66.6 33.26 5.00 1.530 9.947 25.734 18.547 146.000 51.3 64.6 28.77 9.63 1.832 10.149 18.919 18.919 What is what in the .dat file The f(MHz) column is the frequency (MHz) at which the data is evaluated at. The E(deg) column is the approximate 3dB E-plane bandwidth calculated to the nearest 0.1 degree. The H(deg) column is the approximate 3dB H-plane bandwidth calculated to the nearest 0.1 degree. The (R) column is the input resistance in Ohms. The (jX) column is the input reactance in Ohms. The (VSWR) column is the input VSWR, usually refered to a 50 Ohm input, but this may be changed. The Gain (dBi) column is the gain at theta=90 degrees, which is the forward direction of the beam. It is possible that a higher gain occurs at other than 90 degrees, but this is not taken into account. The antenna is seriously at fault if this occurs. The FB(dB) column is the front to back ratio in dB. The Sidelobes(dB) column is the minimum level in dB down from the peak gain of any sidelobe. This is not calculated unless the '-c' option is used, and then only on some optimisation techniques. Example of a .gai File The following is a small section of the .gai file. f(MHz) theta gain-E(dBi) G(E)-peak phi gain-H(dBi) G(H)-peak 144.0000 -90.0000 -12.5584 -21.9444 -180.0000 -12.5584 -21.9444 144.0000 -45.0000 -7.3507 -16.7367 -135.0000 -3.5971 -12.9830 144.0000 0.0000 -999.0000 -1008.3860 -90.0000 -0.9010 -10.2870 144.0000 45.0000 0.1848 -9.2012 -45.0000 4.0261 -5.3599 144.0000 90.0000 9.3860 0.0000 0.0000 9.3860 0.0000 144.0000 135.0000 0.1848 -9.2012 45.0000 4.0261 -5.3599 144.0000 180.0000 -999.0000 -1008.3860 90.0000 -0.9010 -10.2870 144.0000 225.0000 -7.3507 -16.7367 135.0000 -3.5971 -12.9830 144.0000 270.0000 -12.5584 -21.9444 180.0000 -12.5584 -21.9444 What is what in the .gai file The f(MHz) column is the frequency in MHz. The theta column is the angle theta, for which the next two columns refer. The gain-E(dBi) is the gain at theta, relative to an isotropic radiator. This is the E-plane gain. Hence at the peak (theta), this gives the peak forward gain. The G(E)-peak is the gain at theta, relative to the peak gain. Hence at the peak (theta=90 degrees), this is zero. The phi column has nothing to do with the previous 3 columns. It is the angle for which the next two columns refer. The gain-H(dBi) is the gain at phi, relative to an isotropic radiator. This is the H-plane gain. Hence at the peak (phi=0), this gives the peak forward gain. The G(H)-peak is the gain at phi, relative to the peak gain. Hence at the peak (phi=0 degrees), this is zero. Example of a .up File The .up file list the improvements made by optimise to an antenna design. Starting from the original design, the file is appended each time a new better design is found. Here is an example, where the final line is the performance of the 4ele beam with the .dat file shown ear- lier. 1 7.57dBi, 16.93dB F/B, Z=(31.77-56.34j) Ohms, VSWR=3.95, SL=16.95 dB 84 7.58dBi, 16.93dB F/B, Z=(31.78-56.32j) Ohms, VSWR=3.95, SL=16.95 dB 623 7.58dBi, 16.93dB F/B, Z=(31.78-56.28j) Ohms, VSWR=3.95, SL=16.95 dB 89345 9.74dBi, 103.06dB F/B, Z=(37.55 +1.61j) Ohms, VSWR=1.33, SL=17.78 dB What is what in the .up file The first column is an integer specifying the iteration. The other columns, going from left to right are gain(dBi), FB, input impedance, VSWR and level of the most significant sidelobe, in dB down on the peak gain. SEE ALS0 yagi(1), output(1), input(1), optimise(1), first(1) and yagi(5). AUTHORS
Dr. David Kirkby G8WRB (david.kirkby@onetel.net), with help with converting to DOS from Dr. Joe Mack NA3T (mack@fcrfv2.ncifcrf.gov). Version 1.16 24th October 2000 OUTPUT(5)
All times are GMT -4. The time now is 12:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy