04-15-2011
Bash regex
Hello everybody,
I'm clearly not an expert in bash scripting as I've written maybe less than 10 scripts in my life. I'm trying to strip an xml string removing every tag in it. I'm using bash substitution to do so, but apparently I missed something about what is a regex for bash ...
As an example, my input is:
VAR='<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/share/path/to/build/directory</value>'
I use the command:
echo ${VAR#<[^>]*>}
I thought it was supposed to remove the shortest match of a substring starting with < and ending with >. But the output is the exact input string ...
The regex I know are those I use with flex so maybe it is not the same.
PS: The desired output for the example is '/home/share/path/to/build/directory'
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I want to do a regex test and branch based on the test result, but this doesn't seems to work :confused:
if \) ]]
then
echo success
else
echo failed
fi (1 Reply)
Discussion started by: subin_bala
1 Replies
2. Shell Programming and Scripting
It can get very annoying that bash regex =~ is case-sensetive, is there a way to set it to be case-insensetive?
if ]; then
echo match
else
echo no match
fi (8 Replies)
Discussion started by: TehOne
8 Replies
3. Shell Programming and Scripting
Hello
I have a bash script where I need to do a substring replacement like this:
variable2=${variable1/foo/bar}
However, I only want "foo" replaced if it is at the end of the line.
However, this does not work:
variable2=${variable1/foo$/bar}
as you can see I'm using the $ regex for... (2 Replies)
Discussion started by: Ubuntu-UK
2 Replies
4. Shell Programming and Scripting
Hey all,
I have a very simple regular expression that I use when I want to allow only letters with spaces. (I know this regex has a lot of shortcomings, but I'm still trying to learn them)
isAlpha='^*$'However, when I bring this over to BASH it doesn't allow me to enter spaces.
I use the... (3 Replies)
Discussion started by: whyte_rhyno
3 Replies
5. Shell Programming and Scripting
I've been using the following regex below in a bash script on RHEL 5.5 using version
GNU bash, version 3.2.25(1)-release
I've tried using the script on RHEL 6.3 which uses GNU bash, version 4.1.2(1)-release
I assume there's been alot of changes to bash since that's quite a jump in revisions.... (12 Replies)
Discussion started by: woodson2
12 Replies
6. Shell Programming and Scripting
# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi (1 Reply)
Discussion started by: kevin298
1 Replies
7. UNIX for Dummies Questions & Answers
Hi, I am trying to match this word: hexagon-bx.mydomain.com with regex. I have tried this:
"\.*]*$"
So far I have not been successful. I also need to make sure that the regex will match words that just have lowercase letters and numbers in them, such as camera01. How can I create such an... (5 Replies)
Discussion started by: newbie2010
5 Replies
8. UNIX for Dummies Questions & Answers
I am trying to find files using the following by using simple bash script:
if -2014 ]]; then echo "yes";fi
What I need to find are any files with date 08-**-2014 so August 2014 any files.
I can use if -2014 ]]; then echo "yes";fi
That works fine. How do I get files beginning with 08... (1 Reply)
Discussion started by: newbie2010
1 Replies
9. Shell Programming and Scripting
I'm building a script that may received start and end date as parameters. I whant to make it as flexible as possible so I'm accepting epoch and date in a way that "date --date=" command may accept. In order to know if parameter provided is an epoc or a "date --date=" string I evaluate if the value... (2 Replies)
Discussion started by: lramirev
2 Replies
10. Shell Programming and Scripting
I stumbled upon a problem, which I simplified to this:
There is a list of numbers, stored in variable $LIST, lets use `seq 5 25` for demonstration.
There is a number that should be compared against this list. For demonstration I use user input - read VALUE
I am trying to compare RegEx... (2 Replies)
Discussion started by: Zorbeg
2 Replies
LEARN ABOUT REDHAT
cowbuilder
cowbuilder(8) cowdancer cowbuilder(8)
NAME
cowbuilder - a pbuilder wrapper for cowdancer.
SYNOPSIS
cowbuilder [commands] [options]
DESCRIPTION
cowbuilder Executes the specified pbuilder operation with cowdancer
COMMANDS
Most commands invoke pbuilder with the specified commands, see pbuilder manual for details.
--create
Create the base.cow image. The directory for base.cow should be empty, or this command will fail.
--update
Update the base.cow image.
--build .dsc-file
Build a package given a .dsc file
--login
Start a session within the base.cow.
--execute
Execute a command within the base.cow.
--dumpconfig
dump configuration information.
OPTIONS
Most options are the same as pbuilder, except for the following which are handled specially
--buildplace
The place where COW operation takes place.
--basepath
has a very different meaning to basetgz option of pbuilder, since there is no tgz. This option specifies the directory in which the
COW master data is stored, the default being /var/cache/pbuilder/base.cow
--configfile [configuration file to load]
Additional configuration file to read after all other configuration files have been read.
--no-cowdancer-update
Do not use cowdancer on cowbuilder --update. Please use this option when cowdancer is interfering with upgrade process, or cowdancer
itself is being upgraded within chroot.
--debian-etch-workaround
Work around on Debian etch compatibility. cow-shell will search for all files in chroot, but will work.
CONFIGURATION FILES
cowbuilder reads the following configuration files per default.
/usr/share/pbuilder/pbuilderrc
Application default, not to be changed.
/etc/pbuilderrc
System-wide default.
~/.pbuilderrc
User default
anything specified with --configfile option
Additional configuration at runtime.
CONFIGURATION FILE OPTIONS
The possible configuration options are as follows. Others are ignored.
DISTRIBUTION=distribution
BUILDRESULT=directory
BUILDPLACE=directory
BASEPATH=path
MIRRORSITE=http://mirror
NO_COWDANCER_UPDATE=1
See --no-cowdancer-update
DEBIAN_ETCH_WORKAROUND=1
See --debian-etch-workaround
EXAMPLES
cowbuilder --create
Create a base.cow image.
# cowbuilder --create --hookdir /usr/share/doc/pbuilder/examples/workaround/ --distribution etch --debootstrap debootstrap --basepath /var/cache/pbuilder/base-test.cow
bash: /root/.pbuilderrc: No such file or directory
W: /home/dancer/.pbuilderrc does not exist
-> Running in no-targz mode
Distribution is etch.
Building the build environment
-> running debootstrap
/usr/sbin/debootstrap
I: Retrieving Release
.
.
cowbuilder --update
Update the base.cow image.
# cowbuilder --update
bash: /root/.pbuilderrc: No such file or directory
-> Copying COW directory
-> Invoking pbuilder
W: /home/dancer/.pbuilderrc does not exist
-> Running in no-targz mode
-> copying local configuration
-> mounting /proc filesystem
-> mounting /dev/pts filesystem
-> policy-rc.d already exists
Refreshing the base.tgz
-> upgrading packages
.
.
cowbuilder --build test_0.1.dsc
Build the package specified in dsc file, with the base.cow image.
pdebuild --pbuilder cowbuilder
Run
cowbuilder --build
against the current directory.
The current directory should be an extracted Debian source package directory.
Edit
/etc/pbuilderrc
to have
PDEBUILD_PBUILDER=cowbuilder
to make this the default behavior for
pdebuild.
cowbuilder --login --bindmounts /home/dancer
Start a cow-shell session inside base.cow, with
/home/dancer
being bind-mounted to within chroot.
Note that cowbuilder will not cow-protect what is inside
/home/
# cowbuilder --login --bindmount ${HOME}
bash: /root/.pbuilderrc: No such file or directory
-> Copying COW directory
-> Invoking pbuilder
W: /home/dancer/.pbuilderrc does not exist
-> Running in no-targz mode
-> copying local configuration
-> mounting /proc filesystem
-> mounting /dev/pts filesystem
-> Mounting /home/dancer
-> policy-rc.d already exists
-> entering the shell
#
cowbuilder --create --distribution sid --basepath /var/cache/pbuilder/base-test.cow
Create a base.cow image with the path
/var/cache/pbuilder/base-test.cow
and distribution sid.
AUTHOR
Junichi Uekawa (dancer@debian.org)
SEE ALSO
/usr/share/doc/pbuilder/pbuilder-doc.html, pbuilder (8), pdebuild (1)
cowdancer 2007 Jun 17 cowbuilder(8)