Gnu tool; sed awk echo etc to prepend or append string to a file
Looking to add text to a file, example
File example;
I need to take a file with a one line list of hosts separated by commas
and prepend the string " check-hosts: L@" to the line of hosts above (line 2). I need to have two spaces before "check-hosts: L@"
My approach has been to prepend the string " check-hosts: L@" to the file containing the line of hosts. but I am open to other ways as long as I can use the file that contains a list of hosts as the starting poing.
Line 1 nodegroups: needs to be above line 2 in my example.
I need the line printed with echo to append to eof of to exactly line, am i able to do that?
i mean
echo "sysctl -w lalala=1" > to end of file /etc/sysctl.conf
or to the 21st line, if the line exist, open new line and insert text there.
Thx.maybe i'm in wrong topic but anyway... (2 Replies)
I want to print out a directory listing, then append ] to the end of each line. I'm trying to create a list of Wiki links based on folder listings that i can just copy and paste without having to edit 100's of file listings.
Using sed i've figured out to do something like this:
sed... (4 Replies)
Hi,
I have a file 'tmp.dat' that contains the below data:
81763
40829
30405
80452
I want to prepend a ' character to the beginning of every line, and I want to append ', at the end of every line. Below is what I expect:
'81763',
'40829',
'30405',
'80452',
Can anyone help me?
... (3 Replies)
I am trying to replace in multiple files every instance of text that begins with http and add hyperlink characters to it. I can get it to work with the following:sed -e "s/http*.*/<a href=\"&\">&<\/a>/g" *
as long as the http text is at the end of the file. I need it to stop at the end of the... (2 Replies)
I have a file like below
#GROUP A belongs to Asia
GROUP A jojh hans local admin
GROUP A gege fans michel jing jong
#GROUP U belongs to USA
GROUP U jeff goal hello world
My requirement is to grep for first apperence of GROUP A which is not commented and append my name to end of file.... (12 Replies)
hi,
just wanted to make a shortcut of this one
a="a b c"
b=`echo $a | awk '{print $2}'`
echo "the middle is $b"
why can't i do this:
a="a b c"
echo "the middle is ${`echo $a | awk '{print $2}'`}" <- bad substitution :wall:
thanks (6 Replies)
Hi,
I need to replace and append a string in a text if grep is true. For eg:
grep ABC test.txt | grep -v '\.$' | awk {'print $4'} | sed "s/ ?
How do I replace all instances of "print $4" using sed with another sring? Eg of the string returned will be,
lx123
web222
xyz
Want to... (8 Replies)
Hi,
I have a File, which have multiple rows.
Like below
123456 Test1 FNAME JRW#$% PB MO Approver XXXXXX. YYYY
123457 Test2 FNAME JRW#$% PB MO Super XXXXXX. YYYY
123458 Test3 FNAME JRW#$% PB MO Approver XXXXXX. YYYY
I want to search a line which contains PB MO Approver and append... (2 Replies)
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)
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
LEARN ABOUT NETBSD
mknetid
MKNETID(8) BSD System Manager's Manual MKNETID(8)NAME
mknetid -- a NIS filter program
SYNOPSIS
mknetid [-q] [-d domain] [-p passwdfile] [-g groupfile] [-h hostfile] [-m netidfile]
DESCRIPTION
mknetid is used to create a map named netid.byname. The map consists of information from passwd(5), group(5) and hosts(5) eventually con-
catenated with a netid(5) file.
The options are as follows:
-d domain NIS domain to use instead of the default domain.
-g groupfile Alternate group(5) file. Default is /etc/group.
-h hostfile Alternate hosts(5) file. Default is /etc/hosts.
-m netidfile Alternate netid(5) file. Default is /etc/netid.
-p passwdfile Alternate passwd(5) file. Default is /etc/passwd.
-q Keep quiet about multiple occurrences of a uid; ignore all but the first.
FILES
/etc/group
/etc/hosts
/etc/netid
/etc/passwd
SEE ALSO domainname(1), group(5), hosts(5), netid(5), passwd(5), nis(8)AUTHORS
Mats O Jansson <moj@stacken.kth.se>
BSD February 26, 2005 BSD