11-18-2019
Hi Rudi
Thanks for sharing the detail
I tried your solution, and it worked for lines where variable exists exactly 2 times in that particular line.
There are lines in main file where no variable exits or only one variable exits instead of 2 times in the line, then it is giving error.
any suggestion to handle that
Thanks a lot
Rel
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi,
i have file say email.temp looks like
Bell_BB 17
Bell_MONTHLY 888
SOLO_UNBEATABLE 721
and another file r3
Bell BB,Bell_BB
Bell,Bell_MONTHLY
SOLO,SOLO_UNBEATABLE
i want email.temp files $1 say Bell_BB should be replaced by r3 Bell BB and Bell_MONTHLY by... (2 Replies)
Discussion started by: raghavendra.cse
2 Replies
2. Shell Programming and Scripting
Ok, so, let's say I have the variable $GMAILID....How can I use it with sed command so to replace a string in a file? e.g.:
sed -i 's/$GMAILID/test@gmail.com/' /home/$USER/Desktop/sendmail (4 Replies)
Discussion started by: hakermania
4 Replies
3. Shell Programming and Scripting
Can you please point me in the correct direction?
I need a line or script to run though a given directory and find all files with "@domain.local" in there names and simple remove that.
For example if the files were named 1234@domain.local the file would then become 1234. (1 Reply)
Discussion started by: binary-ninja
1 Replies
4. Shell Programming and Scripting
My apologies if this has been answered in a previous post. I've been doing a lot of searching, but I haven't been able to find what I was looking for. Specifically, I am wondering if I can utilize sed and/or awk to locate two strings in a file, and replace everything between those two strings... (12 Replies)
Discussion started by: kiddsupreme
12 Replies
5. Red Hat
Hi all,
Hereby wish to have your advise for below:
Main concept is
I intend to get current directory of my script file.
This script file will be copied to /etc/init.d.
A string in this copy will be replaced with current directory value.
Below is original script file:
... (6 Replies)
Discussion started by: cielle
6 Replies
6. Shell Programming and Scripting
Hi experts,
In my text file I have the following alot of lines like below.
input.k is as follows.
2684717 -194.7050476 64.2345581 150.6500092 0 0
2684718 -213.1575623 62.7032242 150.6500092 0 0
*INCLUDE
$# filename... (3 Replies)
Discussion started by: hamnsan
3 Replies
7. Shell Programming and Scripting
Hi,
I am trying to replace the value of a variable in a file through another script.
Example:
Filename : abc.txt contents:
a=10
b=20
c=30
Need to change the value of, say, b - Tried using the following:
sed "s/${b}/15/g" abc.txt
Have tried various forms of sed (with single quotes,... (4 Replies)
Discussion started by: rituparna_gupta
4 Replies
8. Shell Programming and Scripting
My first comment on every file contains the license message. I want to replace with a new license message. I used the below sed script, which replaces all comments. What is the modification or any other method with awk script for the below to edit only the first comment(license message)?
#sed -f... (1 Reply)
Discussion started by: vpshastry
1 Replies
9. Shell Programming and Scripting
I have a file having some text like:
PATH_ABC=/user/myLocation
I have to replace "/user/myLocation" with a session variable say, $REPLACE_PATH,
where $REPLACE_PATH=/user/myReplaceLocation
The following sed command is not working. It is writing PATH_ABC=$REPLACE_PATH in the file
... (2 Replies)
Discussion started by: SKhan
2 Replies
10. Programming
Dear All,
I am having a requirement to find the difference between 2 files and generate a discrepancy report out of it as an html page. I prefer using diff -y file1 file2 since it gives user friendly layout to know any discrepancy in the record and unique records among the 2 file. Here's how it... (12 Replies)
Discussion started by: Badhrish
12 Replies
LEARN ABOUT DEBIAN
snmail
snmail,v0.3.8(8) System Manager's Manual snmail,v0.3.8(8)
NAME
snmail - mail-to-news filter
SYNOPSIS
snmail [-sP] [listname [prefix]]
DESCRIPTION
snmail reads a single email message on standard input, and writes the converted message to standard output. This output is suitable for
feeding to snstore.
snmail does these conversions: If the first line is a UUCP From_ line, it is silently discarded; a Newsgroups: line is added with the value
of prefixlistname (prefix concatenated with listname), and other existing Newsgroups: lines are removed; and a Path: line is created from
all Received: lines, which are removed; all header lines are unfolded; if no message ID exists, one is created; message IDs in all Refer-
ences: lines and In-Reply-To: lines are collected into a single References: line; all lines are rewritten to end in CRLF; and a lone . on
a line is written at the end of the message.
snmail will accept and pass on messages with invalid header fields.
snmail is meant to be run from a .forward or the /etc/aliases file (if you're using sendmail or similar) or from a .qmail file (if you're
using qmail). snmail may write status or error messages to standard error.
OPTIONS
-s Pipe output to snstore directly, do not write to standard output. This is so the exit status is not lost in a shell pipeline. If
you use this flag, it is also a good idea to also use -c (tell snstore to check if article already exists).
Other options
snmail also accepts options intended for snstore, viz. -c, -v, and -n, and these are passed on uninterpreted.
ARGUMENTS
prefix is the prefix of the newsgroup; if not specified, it defaults to local. (note the trailing .). prefix may not begin with a .
(dot) but it may be empty.
listname
completes the newsgroup name; if not specified, it is the local part of the address in the Return-Path: line if it exists and isn't
empty; otherwise it is the local part of the messages' first From:. So if the message originated from the list <linux-lem-
mings@vger.rutgers.edu>, then the default newsgroup becomes local.linux-lemmings. listname may be empty if prefix isn't.
You may want to have a file /var/spool/sn/prefixlistname/.nopost to deny posting from all and sundry, to prevent the mailing list
newsgroup from being contaminated.
prefix and listname may contain uppercase characters; these are converted to lower case.
USAGE
There are two ways of forwarding mail to the sn news spool: directly from a user's mail address; or forwarded to a central address and then
invoking snmail. The central concern here is permissions; while anyone can run snmail, not everyone may store mail in the spool. Mail
setups vary a lot, so basically you're on your own here.
ENVIRONMENT VARIABLES
SNROOT If this is set and is not empty, the value is used in place of /var/spool/sn, the default news spool directory.
PATH If -s was specified, determines where to look for snstore, before looking in /usr/sbin.
EXIT STATUS
snmail exits 0 if the message was successfully converted and written, or if the message ID already exists in the ID database and the mes-
sage was not stored or converted.
snmail exits with 1 on usage error, 2 on operational error, 3 if the mail message wasn't in the proper format.
N.B. Harold Tay snmail,v0.3.8(8)