I hope you have code to store the contents of file "amended_file_01" into variable "amended_file01"; after which a minor adjustment to your sed one-liner should do the trick:
This User Gave Thanks to balajesuri For This Post:
using sed to replace a specific string on a specific line number using variables
this is where i am at
grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean
grep -n Destination... (2 Replies)
Hello ,
I need to extract data from specific byte positions of a file.
I have tried the below command
awk ' { printf "%s", substr($0, 642363,642369}' filename
to extract data between byte positions
642363 and 642369 .
However I did not get the expected result.
I am new to awk... (6 Replies)
I am attempting to replace positions 44-46 with YYY if positions 48-50 = XXX.
awk -F "" '{if (substr($0,48,3)=="XXX") $44="YYY"}1' OFS="" $filename > $tempfile
But this is not working, 44-46 is still spaces in my tempfile instead of YYY. Any suggestions would be greatly appreciated. (9 Replies)
From the existing file, I need to replace specific contents possibly with var every time when the user changes the var.
e.g the contents in the file file.txt is 'My name is $n and I am $y years old' and every time user changed the var outside the file, the contents of the file should be created... (4 Replies)
I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work.
Brief overview:
I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
my requirement is,
consider a file output
cat output
blah sdjfhjkd jsdfhjksdh
sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf
hellow there
this doesnt look good
et cetc etc
etcetera
i want to replace a line of line number 4 ("this doesnt look good") with some other line
... (3 Replies)
Hello,
I have two files: file1 and file2
file1 has the following info:
---
host: "localhost"
port: 3000
reporter_type: "zookeeper"
zk_hosts:
- "localhost:2181"
file2 contains an IP address (1.1.1.1)
What I want to do is replace localhost with 1.1.1.1, so that the... (4 Replies)
Hi,
I have a file with hundreds of lines. I want to search for particular lines starting with 4000, search and replace the 137-139 position characters; which will be '000', with '036'. Can all of this be done without opening a temp file and then moving that temp file to the original file name.
... (7 Replies)
I have a fixed-length positional file. I am trying to replace content of position 4-13 (length=10) with xxxxxxxxxx.
Sample 2 rows in this file:
H0187459823 172SMITH, JOE
H0112345678 172DOE, JANE
In this example 87459823 (from 1st line) and 12345678 (from 2nd line) (both in position... (3 Replies)
Discussion started by: Diver181
3 Replies
LEARN ABOUT ULTRIX
pr
pr(1) General Commands Manual pr(1)Name
pr - print files
Syntax
pr [ options ] [ files ]
Description
The command prints the named files on the standard output. If file is designated by a minus sign (-), or if no files are specified the
command assumes standard input. By default, the listing is separated into pages, each headed by the page number, a date and time, and the
name of the file.
By default, columns are of equal width, separated by at least one space. Lines that do not fit are truncated. However, if the -s option is
used, lines are not truncated and columns are separated by the separation character.
If the standard output is associated with a terminal, error messages are withheld until has finished printing.
Options
The following options can be used singly or in combination:
-a Prints multi-column output across the page.
-b Prints blank headers.
-d Double-spaces the output.
-eck Expands input tabs to character positions k+1, 2*k+1, 3*k+1,... n*k+1. If k is 0 or is omitted, tabs are set at every eighth posi-
tion. Tab characters in the input are expanded into the appropriate number of spaces. The default for c (any non-digit character)
is the tab character; therefore, if c is given, it is treated as the input tab character.
-f Uses form-feed character for new pages. The default is to use a sequence of line-feeds. The -f option causes the command to pause
before beginning the first page if the standard output is associated with a terminal.
-h Uses the next argument as the header to be printed instead of the file name.
-ick Replaces white space in output by inserting tabs to character positions k+1, 2*k+1, 3*k+1,...n*k+1. If k is 0 or is omitted, tabs
are set at every eighth position. The default for c (any non-digit character) is the tab character; therefore, if c is given, it
is treated as the input tab character.
+k Begins printing with page k (default is 1).
-k Produces k-column output (default is 1). The -e and -i options are assumed for multi-column output.
-lk Sets the length of a page to k lines. The default is 66 lines.
-m Merges and prints all files simultaneously, one per column (overrides the -k, and -a options).
-nck Numbers lines. The default for k is 20. The number occupies the first k+1 character positions of each column of normal output or
each line of -m output. If c, which is any non-digit character is given, it is appended to the line number to separate it from
whatever follows. The default for c is a tab.
-ok Offsets each line by k character positions (default is 0). The number of character positions per line is the sum of the width and
offset.
-p Pauses before beginning each page if the output is directed to a terminal. The command rings the bell at the terminal and awaits a
carriage return.
-r Suppresses diagnostic reports on failure to open files.
-sc Separates columns by the single character c instead of by the appropriate number of spaces (default for c is a tab).
-t Suppresses the five-line identifying header and the five-line trailer normally supplied for each page. The -t option causes the
command to quit printing after the last line of each file without spacing to the end of the page.
-wk Sets the width of a line to k character positions. The default is 72 for equal-width multi-column output; otherwise there is no
limit.
Examples
Print file1 and file2 as a double-spaced, three-column listing with the heading: file list.
pr -3dh "file list" file1 file2
Write file1 on file2, expanding tabs to columns 10, 19, 28, 37,...:
pr -e9 -t <file1>file2
Files
/dev/tty* to suspend messages
See Alsocat(1)pr(1)