My data is xml'ish (here is an excerpt) :-
<bag name="mybag1" version="1.0"/>
<contents id="coins"/>
<bag name="mybag2" version="1.1"/>
<contents id="clothes"/>
<contents id="shoes"/>
<bag name="mybag3" version="1.6"/>
I want to delete line containing mybag2 and its subsequent... (5 Replies)
Hi!
From a file like this one :
hello
...
PATTERN1
...
lines between patterns
..
PATTERN2
...
I would like to extract only the lines between patterns, probably with awk I think?
Thanks a lot for your help,
Tipi (5 Replies)
Hi,
From the sample file below
Conditions
1) Pattern Range must start with "ALTER TABLE"
2) Pattern Range ends when it finds ";"
3) Between this range i want to select all the patterns that contain pattern " MOVE "
Note : I would like to exclude the above pattern matches and print... (1 Reply)
Hi,
Here is a sample of my Test File
$ cat TestFile1
Prompt Table DQZ_ALTER_SCHEMA_ID;
ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID MONITORING;
ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID STORAGE ( NEXT 3464K );
Prompt Table DQZ_ALTER_SCHEMA_ID;
ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID
MOVE LOB... (16 Replies)
Hi,
I have a file like below:
.
.
.
.
Jack is going home
Jack is going to school
Jack is sleeping
Jack is eating dinner
John is going home
John is eating breakfast
.
.
.
The specific line is:
Jack is going home (2 Replies)
Hi folks,
I have a file which contains several occurences of 2 different patterns. I need to find out the line of first occurence of pattern2 starting after the position of first occurence of pattern1.
example file:
aaaa
pattern2
bbbb
pattern1
ccc
pattern2
ddd
pattern1
eee
pattern2... (9 Replies)
Hi all!
How can I delete all the text starting from <string1> to <string2> in all the .txt files of the folder "FOLDER" ?
Thanks a lot!
mjomba
...
</s>
<s>
<w></w>
</s>
<s>
...
to get: (1 Reply)
Hello, I'm looking for sed solution to change
...
<li>keyword</li>
<li>keyword
<li>keyword</li>
<li>keyword
<li>keyword</li>
...
to
...
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
...
I.e., if lines beginning with <li> do not end with... (3 Replies)
I have the below 2 files:
1) Third field from file1.txt should be compared to the first field of lookup.txt.
2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt.
3)Else just print the line from file1.txt.
File1.txt:... (4 Replies)
Version: RHEL 6.5
In the below text file, I want to find the lines which has the string JOHN , KATE and STEVE in it.
The logic is to grep with an AND condition ie. get all lines with JOHN AND KATE AND STEVE
$ cat sometext.txt
PHILIP worked in HR
JOHN along with KATE fixed several IT... (4 Replies)
Discussion started by: John K
4 Replies
LEARN ABOUT CENTOS
shell-quote
SHELL-QUOTE(1) User Contributed Perl Documentation SHELL-QUOTE(1)NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS --debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.16.3 2010-06-11 SHELL-QUOTE(1)