Affordable Web Site Design & Hosting. Domain Registrations [ $11/year ] 86QM
___ Domain Registrations [ $11/year ] Unbeatable Hosting Deals!!! Full site hosting from [ $4.45/month ] (50 MB 1GB Transfer) PHP, Mysql, Majordomo Mail List Server, POP, IMAP, SMTP, CGI, Perl... Save $50 on Ensim Control Panel license on all hosting plans!!! Amazing Aplications Preinstalled http://www.iolenterprises.com Profit 35% as a reseller and 10% of subreseller sales. Get $10 upon sign up and 11 Free Professional Marketing Ebooks ___ --- Hu lesirebimoc xec letobosotur baguti mo vemafe mamasar torilu pe cikisatafa tilitoc ticabadac nehacexo riliminefop samami gamun lum mece sid mocu rida saw te pitamo . ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
PIPESTATUS within assignment statements.
a=$(COMMAND1 | COMMAND2 | COMMAND3) How can I get return status from COMMAND2? Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 uname output: Linux pepinux 2.6.18-1-686 #1 SMP Mon Sep 25 00:42:11 UTC 2006 i686 GNU/Linux Machine Type: i486-pc-linux-gnu Bash Version: 3.1 Patch Level: 17 Release Status: release Description: host$ a=$(COMMAND1 | COMMAND2 | COMMAND3) host$ echo ${PIPESTATUS[1]} returnstatus_command2 host$ Repeat-By: host$ a=$(COMMAND1 | COMMAND2 | COMMAND3) host$ echo ${PIPESTATUS[1]} Fix: host$ set -o pipefail or anything similar ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Processing a file into smaller chunks
Dear all, I'm a newbie with bash programming and I'm trying to process a file into smaller chunks. Let's say I've to process the file below ('X' and 'Y' are any possible float number): 0 0 0 0 0 0 0 0 0 0 0 0 X X X X X 1.70 0 0 0 0 0 0 X X X X X 1.60 0 0 0 0 0 0 X X X X X 1.30 Y Y Y Y Y 1.90 0 0 0 0 0 0 0 0 0 0 0 0 X X X X X 2.10 The lines containing 0’s can be thought as being delimiters. I need to find between the delimiters, which line has the highest value in the last column (column#6), and, just output the corresponding line. Does anybody could shed some light on it? An example of the desired output would be: X X X X X 1.70 X X X X X 1.60 Y Y Y Y Y 1.90 X X X X X 2.10 Is it possible to obtain such a result using bash scripting? Best regards
string to integer
Dear all, I have a several directories with *.jpg images. The image files are named as ascending numbers and I would like to retrieve the lowest and largest image number in each directory. An example of the content of a directory is given below: /bla/bla/bla/dir1 -> 0.jpg -> 1.jpg -> -> 09001.jpg The desired output would be the integer numbers: 0 and 9001 With the code below, I'm able to retrieve in "seqInterval" array, which is the lowest and largest image number as strings. seqDir="/bla/bla/bla/dir1" seqInterval=($(find $seqDir -name "*.jpg" | sort | sed -n -e '1p;$p' | sed -e 's|^.*/||' -e 's/\.[^.]*$//')) in our example, I obtain sth. like: seqInterval[0] is equal to "0" and seqInterval[1] is equal to "09001" Since those are string numbers, I was wondering which is the best way to convert those strings into integer numbers (seqInterval[0]=0 and seqInterval[1]=9001)? I tried the code below, but it doesn't work properly, any suggestions? startImg=$(printf '%d' ${seqInterval[0]}) endImg=$((printf '%d' ${seqInterval[1]})) Best whishes
Re: string to integer
On Mar 19, 12:39 pm, Javier Montoya wrote: > Dear all, > > I have a several directories with *.jpg images. The image files are > named as ascending numbers and I would like to retrieve the lowest and > largest image number in each directory. An example of the content of a > directory is given below: > /bla/bla/bla/dir1 > -> 0.jpg > -> 1.jpg > -> > -> 09001.jpg > > The desired output would be the integer numbers: 0 and 9001 > With the code below, I'm able to retrieve in "seqInterval" array, > which is the lowest and largest image number as strings. > seqDir="/bla/bla/bla/dir1" > seqInterval=($(find $seqDir -name "*.jpg" | sort | sed -n -e '1p;$p' | > sed -e 's|^.*/||' -e 's/\.[^.]*$//')) > in our example, I obtain sth. like: > seqInterval[0] is equal to "0" and seqInterval[1] is equal to > "09001" > Since those are string numbers, I was wondering which is the best way > to convert those strings into integer numbers (seqInterval[0]=0 and > seqInterval[1]=9001)? > > I tried the code below, but it doesn't work properly, any suggestions? > startImg=$(printf '%d' ${seqInterval[0]}) > endImg=$((printf '%d' ${seqInterval[1]})) > > Best whishes Dear all, I found a solution: startImg=$(printf '%d' ${seqInterval[0]//0/}) endImg=$(printf '%d' ${seqInterval[1]//0/}) Is there's a better way, pls let me know!
Re: string to integer
On Mar 19, 6:04 pm, DennisW wrote: > On Mar 19, 6:50 am, Javier Montoya wrote: > > > > > On Mar 19, 12:39 pm, Javier Montoya wrote: > > > > Dear all, > > > > I have a several directories with *.jpg images. The image files are > > > named as ascending numbers and I would like to retrieve the lowest and > > > largest image number in each directory. An example of the content of a > > > directory is given below: > > > /bla/bla/bla/dir1 > > > -> 0.jpg > > > -> 1.jpg > > > -> > > > -> 09001.jpg > > > > The desired output would be the integer numbers: 0 and 9001 > > > With the code below, I'm able to retrieve in "seqInterval" array, > > > which is the lowest and largest image number as strings. > > > seqDir="/bla/bla/bla/dir1" > > > seqInterval=($(find $seqDir -name "*.jpg" | sort | sed -n -e '1p;$p' | > > > sed -e 's|^.*/||' -e 's/\.[^.]*$//')) > > > in our example, I obtain sth. like: > > > seqInterval[0] is equal to "0" and seqInterval[1] is equal to > > > "09001" > > > Since those are string numbers, I was wondering which is the best way > > > to convert those strings into integer numbers (seqInterval[0]=0 and > > > seqInterval[1]=9001)? > > > > I tried the code below, but it doesn't work properly, any suggestions? > > > startImg=$(printf '%d' ${seqInterval[0]}) > > > endImg=$((printf '%d' ${seqInterval[1]})) > > > > Best whishes > > > Dear all, > > > I found a solution: > > > startImg=$(printf '%d' ${seqInterval[0]//0/}) > > endImg=$(printf '%d' ${seqInterval[1]//0/}) > > > Is there's a better way, pls let me know! > > In the case of 09001 your command results in "91" > > Try: > > shopt -s extglob > printf '%d' ${seqInterval[0]/#*(0)/} > printf '%d' ${seqInterval[1]/#*(0)/} > > which says "delete a sequence of zero or more '*()' zeros anchored at > the beginning '#' of the string" Thanks Dennis! But in the case of 00, I obtain an empty value. Ideally, I should keep just one zero. Best wishes