10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys,
I'm wondering what the best way would be to reverse words in a string based on certain characters.
For example:
echo Word1Word2Word3Word4 | sed '
/\n/ !G
s/\(Word.\)\(.*\n\)/&\2\1/
//D
'
This returns:
Word4Word3Word2Word1
I'm no sed expert but... (2 Replies)
Discussion started by: Subbeh
2 Replies
2. Shell Programming and Scripting
I have a requirement where I need to add a variable value based on a pattern match. When I try this it works:
sed '/IS_ETL_DEV/a\
ABCD' File1.txt > File1.tmp
Now I want to replace IS _ETL_DEV with a variable like $Pattern and replace the values ABCD with a variable $Var the value "$$XYZ=1".... (4 Replies)
Discussion started by: vskr72
4 Replies
3. Shell Programming and Scripting
Hi. I have to swap the first and the third word in all lines of a txt file using sed.
Separators between words are: any charachter, except intervall.
I hope, you'll understand what I want to do. my english is not so good, sorry for that:) (10 Replies)
Discussion started by: T720
10 Replies
4. Shell Programming and Scripting
Hi ,
I have a file myhost.txt which contains below,
127.0.0.1 localhost
1.17.1.5 atrpx958
11.17.10.11 atrpx958zone nsybhost
I need to append words only after "atrpx958" like 'myhost' and 'libhost' and not after atrpx958zone.
How to search the word atrpx958(which is hostname) only,... (5 Replies)
Discussion started by: gsreeni
5 Replies
5. Shell Programming and Scripting
Hi ,
I have a file myhost.txt which contains below,
127.0.0.1 localhost
1.17.1.5 atrpx958
11.17.10.11 atrpx958zone nsybhost
I need to append words only after "atrpx958" like 'myhost' and 'libhost' and not after atrpx958zone.
How to search the word atrpx958 only in... (2 Replies)
Discussion started by: gsreeni
2 Replies
6. Shell Programming and Scripting
Hi all,
I want to make an script using sed that removes everything between 'begin' (including the line that has it) and 'end1' or 'end2', not removing this line.
Let me paste an 2 examples:
anything before
any string begin
few lines of content
end1
anything after
anything before
any... (4 Replies)
Discussion started by: meuser
4 Replies
7. Shell Programming and Scripting
Hello all,
I want to use sed to append a variable stored in $i, how do i do that?
$i contains a path to a directory and i want to append it before the result i get from awk statement, before affecting awk results.
rite now out put i get from code below is:-
The path is:... (2 Replies)
Discussion started by: asirohi
2 Replies
8. Shell Programming and Scripting
I've following sed command working fine -
sed '/search_pattern1/ !s/pattern1/pattern2/" file
Now, I want to search two patterns - search_pattern1 and search_pattern2 .
How can put these into above sed statement ?
Thanks in advance. (12 Replies)
Discussion started by: ajitkumar2
12 Replies
9. Shell Programming and Scripting
Hi Unix gurus
This is my first post here. I have a file which looks like this:
string1,string2
,string3
,string4
...
...
I need to append all words below first line to the first line, ie
string1,string2,string3,string4,...
Bear in mind that it is not known how many lines follow... (11 Replies)
Discussion started by: lmatlebyane
11 Replies
10. UNIX for Dummies Questions & Answers
Hi,
I have the following codes below that aims to delete every words between two pattern word. Say I have the files
To delete every word between WISH_LIST=" and " I used the below codes (but its not working):
#!/bin/sh
sed '
/WISH_LIST=\"/ {
N
/\n.*\"/ {... (3 Replies)
Discussion started by: Orbix
3 Replies