Hello All,
How to replace a string in nth line of a file using sed or awk.
For Ex: test.txt
Line 1 : TEST1 TEST2 TEST3
Line 2 : TEST1 TEST2 TEST3 TEST4
Line 3 : TEST1 TEST2 TEST3 TEST5
Line 4 : TEST1 TEST2 TEST3 TEST6
Line 5 : TEST1 TEST2 TEST3 TEST7
i want to go to 4th line of a... (1 Reply)
I have several files (around 50) that have the similar format. I need to extract the 5th line from every file and output that into a text file. So far, I have been able to figure out how to do it for a single file:
$ awk 'NR==5' text1.txt > results.txt
OR
$ sed -n '5p' text1.txt > results.txt... (6 Replies)
Hi all,
assume that i am having the following line in a file called file1.
triumph and disaster must be treated same.
I want to replace this line with.
follow excellence success will chase you.
is it possible to do this using sed. if possible kindly post me the... (2 Replies)
Hi
I have requirement to find nth occurrence in a file and capture data from with in lines (between lines)
Data in File.
<QUOTE>
<SESSION>
<ATTRIBUTE NAME='Parameter Filename' VALUE='file1.parm'/>
<ATTRIBUTE NAME='Service Name' VALUE='None'/>
</SESSION>
<SESSION>
<ATTRIBUTE... (6 Replies)
There is already one thread with the same heading. But here the case is little different.
i have a line which have a field separator '|'
abc|def|ghi|jkl|mno|pqr|stu|vwx|yz
I want to replace every 3rd occurance + next character with the same + newline character.. I mean i want to enter a... (6 Replies)
Greetings experts. Searched the forums (perhaps not hard enough?) - Am searching for a method to capture all output from a log file following the nth occurrence of a known string.
Background:
Using bash, I want to monitor my Oracle DB alert log file. The script will count the total # of... (2 Replies)
Hi,
I am getting crazy after days on looking at it:
Bash in Ubuntu 12.04.1
I want to do this:
pattern="system /path1/file1 file1"
new_pattern=" data /path2/file2 file2"
file to edit: data.db
- I need to search in the file data.db for the nth occurrence of pattern
- pattern must... (14 Replies)
Please can someone help with this?
I have a file with lines as follows:
word1 word2 word3 word4 word5 word6 word7 word8
word1 word2 word3 word4 word5 word6 word7 word8
word1 word2 word3 word4 word5 word6 word7 word8
word1 word2 word3 word4 word5 word6 word7 word8
When I use the... (7 Replies)
Hi All,
I am very new to shell scripting and tried to search this in the forum but no luck.
Requirment:
I have an input file which is comma separated. I need to replace the value in 4th column with another value. This has to happen for all the lines in the file.
Sample data:
Input... (2 Replies)
Hello,
Below command trims right after the nth occurrence of a string.
When I try in while loop, it is not working.
In Terminal
IFS=/ ; read -ra val < Textfile ; echo "${val:0:3}"
It gives only one line:
sunday/monday/tuesday
Textfile:
sunday/monday/tuesday/wednesday/thursday... (2 Replies)
Discussion started by: baris35
2 Replies
LEARN ABOUT OSF1
rlam
RLAM(1) General Commands Manual RLAM(1)NAME
rlam - laminate records from multiple files
SYNOPSIS
rlam [ -tS ][ -u ][ -iaN | -ifN | -idN | -iiN | -iwN | -ibN ] input1 input2 ..
DESCRIPTION
Rlam simply joins records (or lines) from multiple inputs, separating them with the given string (TAB by default). Different separators
may be given for different files by specifying additional -t options in between each file name. Note that there is no space between this
option and its argument. If none of the input files uses an ASCII separator, then no end-of-line character will be printed, either.
An input is either a stream or a command. Commands are given in quotes, and begin with an exclamantion point ('!'). If the inputs do not
have the same number of lines, then shorter files will stop contributing to the output as they run out.
The -ia option may be used to specify ASCII input (the default), or the -if option may be used to indicated binary IEEE 32-bit floats on
input. Similarly, the -id and -ii options may be used to indicate binary 64-bit doubles or integer words, respectively. The -iw option
specifies 2-byte short words, and the -ib option specifies bytes. If a number is immediately follows any of these options, then it indi-
cates that multiple such values are expected for each record. For example, -if3 indicates three floats per input record for the next named
input. In the case of the -ia option, no number indicates one line per input record, and numbers greater than zero indicate that many
characters exactly per record. For binary input formts, no number implies one value per record. For anything other than EOL-separated
input, the default tab separator is reset to the empty string.
A hyphen ('-') by itself can be used to indicate the standard input, and may appear multiple times. The -u option forces output after each
record (i.e., one run through inputs).
EXAMPLE
To join files output1 and output2, separated by a comma:
rlam -t, output1 output2
To join a file with line numbers (starting at 0) and its reverse:
cnt `wc -l < lam.c` | rlam - -t: lam.c -t '!tail -r lam.c'
To join four data files, each having three doubles per record:
rlam -id3 file1.dbl file2.dbl file3.dbl file4.dbl > combined.dbl
AUTHOR
Greg Ward
SEE ALSO cnt(1), histo(1), neaten(1), rcalc(1), tabfunc(1), total(1)RADIANCE 7/8/97 RLAM(1)