It's probably a simple problem for a sed guru, if only they knew what the line looked like. Always provide a sample of the input you want people to help you with, and don't forget to mention any special cases if there are any.
As i don't know the intricacies of the actual file here are some suggestions:
This will replace any string of non-spaces/non-full-stops, followed by a full stop, followed by a series of non-spaces by the part up to the first full stop:
In the regexp there are surrounding spaces to split on word boundaries, therefore the regexp will not work with "words" at the beginning or the end of a line. Furthermore, if there are "words" with full stops in them they would be shortened too (like in "my.name@emailadress.com" -> "my").
To catch FQDNs at line beginnings or endings in the same way you could add two more regexps:
If you can limit the valid characters for domain names any further you can of course fine-tune this mechanism to catch less non-domainnames. To adress my example of the email-address above, for instance:
This would leave email addresses untouched, because "@" is no longer considered a valid character in an FQDN.
I have a file and I want to remove quotes from the word " ` " through sed command but unable to remove
I am using below command
sed s/"`XYZ`"/"ZXY"/g file1.txt > file2.txt
But this is not working. How can we remove "`" through sed command (2 Replies)
trying to write up a script to put the suffix back.
heres what I have but can't get it to do anything :(
would like it to be name.date.suffix
rsync -zrlpoDtub --suffix=".`date +%Y%m%d%k%M%S`.~" --bwlimit=1024 /mymounts/test1/ /mymounts/test2/
while IFS=. read -r -u 9 -d '' name... (1 Reply)
Is there an easy way in sed to remove a character and values
after that character?
ex:
blackout_10-11-2011(NODE_LEVEL)
I want to remove '(' and everything after. so I will only have.
blackout_10-11-2011
I can use a cut command to do this but interested in seeing how its done... (1 Reply)
I have a source text file that contains something like this:
<start_template>
bool function( void *<var_name> )
{
// Blah Blah
}
</start_template>
Following is used to remove this template from source file.
template=$(sed -n -e '/<start_template>/,/<\/start_template>/{... (4 Replies)
Hi all,
Im trying to make a proper hosts.allow with the lists of sshbl.org to block the ssh brute force attackers.
The list is a text file with an IP on every line.
What I've gotten up sofar is to prefix "sshd : " on every line, but I need a " : deny" suffix behind every line as well. ... (9 Replies)
I have this code that parses the output of a reverse dns lookup to a domain name
nslookup $IP | sed -n 's/.*arpa.*name = \(.*\)/\1/p'
But my ouput is always
randomsite.com.
Notice the period tacked on to the end. How do I correct this so it is just
randomsite.com
Thank you. (1 Reply)
Dear Expert,
i have linux box that is running in the windows domain, BUT did not being a member of the domain. as I am not the System Administrator so I have no control on the server in the network, such as modify dns entry , add the linux box in AD and domain record and so on that relevant.
... (2 Replies)
Hi,
I have a file with the text below. How do i remove the character "%" from the text file using sed ? Can anybody help ?
0%
68%
72%
0%
54%
33%
75%
24%
6%
59%
77%
77%
33% (6 Replies)
How do we delete all carriage returns after a particular string using sed inside a K Shell?
e.g. I have a text file named file1 below:
$ more file1
Group#=1 User=A
Role=a1
Group#=2 User=B
Role=a1
Role=b1
Group#=3 User=C
Role=b1
I want the carriage returns to be delete on the... (12 Replies)