01-28-2008
Replacing lines in text files
Hi,
I have 2 sets of text files. I need to take a field from a certain line in set 1 and put it in the same place in set b. The line appears once per file, in different places but is a set format and has the unique word "ANTENNA" in it and is always 81 characters long. Example from set a:
" 0.0000 0.0000 0.0000 ANTENNA: DELTA H/E/N"
Example from set b
" 0.2160 0.0000 0.0000 ANTENNA: DELTA H/E/N"
The bold bit is the field I'm trying to change and will be a random float in both sets.
I've been trying to do it like this:
#!/bin/ksh
old_line=`grep ANTENNA ./file1.txt`
new_line=`grep ANTENNA ./file2.txt`
sed "s/${old_line}/${new_line}/" file1.txt >tmp2 #substitute old line with new line in file 1 and output to tmp2
But this doesn't work, probably because I have forward slashes in my grep lines which sed interprets as some sort of regexp. How can I escape these when they are embedded in a variable? Am I quoting incorectly? Or is there a much better way?
Jon
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I want to delete first five and last five lines in text files without opening the file and also i want to keep the same file name for all the files.
Thanks in advance!!!
Ragav (10 Replies)
Discussion started by: ragavendran31
10 Replies
2. Shell Programming and Scripting
Hi all,
I am trying to replace a few lines with other lines of all files in a directory which contain those few lines.
say - there are some 10 files in a dir having the same 4 lines as 1.txt at the starting
1.txt
line 1
line 2
line 3
line 4
....................................... (1 Reply)
Discussion started by: rooster005
1 Replies
3. Shell Programming and Scripting
I just created a file in vi, looks like this:
Hello nobody
nobody
What I need is to have sed change the file so it looks like this:
Hello everybody
In other words, the sed query needs to look for both instances of "nobody" before it puts the word "everybody" on the first line. ... (2 Replies)
Discussion started by: calrog
2 Replies
4. Shell Programming and Scripting
Dear All,
Regards of the Day.
I have a text file with some functions:
Function1
{
parameter 1
parameter 2
parameter 3
}
end
Function2
{
parameter 1
parameter 2
parameter 3
} (1 Reply)
Discussion started by: ashisharora
1 Replies
5. Shell Programming and Scripting
Hello Masters,
I have two subtitles file with different language like below
First file :
1
00:00:41,136 --> 00:00:43,900
2
00:00:55,383 --> 00:00:58,477
<i> Ladies and gentlemen,</i>
<i>this is Simon Barsinister,</i>
3
00:00:58,553 --> 00:01:00,521
<i>the wickedest man in the... (8 Replies)
Discussion started by: rk4k
8 Replies
6. Shell Programming and Scripting
Dear Experts,
I am new to unix shell programming. I need to write a script which needs to edit 4 text files.
File 1:- PCH_Test.txt
File 2:- PCT_Test.txt
File 3:- PCY_Test.txt
File 4:- PCW_Test.txt
PCH_Test.txt
First it needs to get into PCH_Test file and prefix the 6th coloumn... (2 Replies)
Discussion started by: phani333
2 Replies
7. Shell Programming and Scripting
Well, to make another post at this helpful forum :b::D:
I recently tried something like this, I want to replace all those numberings/letters that are located
between <string>file://localhost/var/mobile/Applications/ and /Documents/</string>
numberings =----
replace with:
first... (6 Replies)
Discussion started by: pasc
6 Replies
8. Shell Programming and Scripting
Hi friends,
This is sed & awk type question.
I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example
###start of input text file ####
abc
def
ghi
1
2
3
4
kjld
random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies
9. Shell Programming and Scripting
Hallo Everyone.
I have to admit I'm shell scripting illiterate . I need to find certain strings in several text files and replace each of the string by unique & corresponding text.
I prepared a csv file with 3 columns: <filename>;<old_pattern>;<new_pattern>
... (5 Replies)
Discussion started by: gordom
5 Replies
10. Shell Programming and Scripting
I dont even have a sample script cause I dont know where to start from. My data lookes like this
> sat#16 #data: 15 site:UNZA baseline: 205.9151
0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722
0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies
LEARN ABOUT DEBIAN
uhd_rx_nogui
UHD_RX_NOGUI(1) User Commands UHD_RX_NOGUI(1)
NAME
uhd_rx_nogui - GNU Radio receiver
SYNOPSIS
uhd_rx_nogui.py [options]
DESCRIPTION
Command line GNU Radio receiver that takes signal from a UHD peripheral receiver and sends demodulated audio to the sound device.
OPTIONS
-h, --help
show this help message and exit
-a ARGS, --args=ARGS
UHD device address args , [default=]
--spec=SPEC
Subdevice of UHD device where appropriate
-A ANTENNA, --antenna=ANTENNA
select Rx Antenna where appropriate [default=none]
-f Hz, --frequency=Hz
set receive frequency to Hz [default=none]
-c Hz, --calibration=Hz
set frequency offset to Hz [default=0.0]
-g dB, --gain=dB
set RF gain [default is midpoint]
-m TYPE, --modulation=TYPE
set modulation type (AM,FM) [default=none]
-o RATE, --output-rate=RATE
set audio output rate to RATE [default=32000]
-r dB, --rf-squelch=dB
set RF squelch to dB [default=-50.0]
-p FREQ, --ctcss=FREQ
set CTCSS squelch to FREQ [default=none]
-O AUDIO_OUTPUT, --audio-output=AUDIO_OUTPUT
pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp
SEE ALSO
uhd_fft(1) uhd_rx_cfile(1) uhd_siggen(1) uhd_siggen_gui(1)
uhd_rx_nogui 3.5 December 2011 UHD_RX_NOGUI(1)