Re: Scripting question

2012-04-17 Thread Daniel Landau
On Tue, Apr 17, 2012 at 4:52 PM, Eduardo M KALINOWSKI
 wrote:
> On Ter, 17 Abr 2012, Chris wrote:
>> I would like have the Smtp: replaced with To:  leaving all that follows in
>> each line untouched and piped into a new file.
>
> man sed
>

Read that too, but try also searching online for "sed tutorial". The
line to do this specific thing is:

$ sed -e 's/^Smtp:/To:/' oldfile > newfile

Daniel Landau


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAPBTYu4KBgb55tjHHXysWed=+s2=kDnSECYNT1i=h1jowm9...@mail.gmail.com



Re: Scripting question

2012-04-17 Thread emmanuel segura
perl -e 'while(<>){chomp; s/root/Root/g; print  "$_\n"; }' /etc/passwd



Il giorno 17 aprile 2012 15:52, Eduardo M KALINOWSKI <
edua...@kalinowski.com.br> ha scritto:

> On Ter, 17 Abr 2012, Chris wrote:
>
>> Firstly I petty much suck at scripting so I need help.
>>
>> I have a file where each line begins with
>>
>> Smtp:
>>
>> I would like have the Smtp: replaced with To:  leaving all that follows
>> in each line untouched and piped into a new file.
>>
>
> man sed
>
>
> --
> The majority of husbands remind me of an orangutang trying to play the
> violin.
>-- Honor' e DeBalzac
>
> Eduardo M KALINOWSKI
> edua...@kalinowski.com.br
>
>
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.**debian.orgwith a
> subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
> Archive: http://lists.debian.org/**20120417105220.Horde.**
> 5niudUisJlFPjXWUaIYVfNA@mail.**kalinowski.com.br
>
>


-- 
esta es mi vida e me la vivo hasta que dios quiera


Re: Scripting question

2012-04-17 Thread Eduardo M KALINOWSKI

On Ter, 17 Abr 2012, Chris wrote:

Firstly I petty much suck at scripting so I need help.

I have a file where each line begins with

Smtp:

I would like have the Smtp: replaced with To:  leaving all that  
follows in each line untouched and piped into a new file.


man sed


--
The majority of husbands remind me of an orangutang trying to play the violin.
-- Honor'e DeBalzac

Eduardo M KALINOWSKI
edua...@kalinowski.com.br




--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Archive: 
http://lists.debian.org/20120417105220.horde.5niuduisjlfpjxwuaiyv...@mail.kalinowski.com.br



Re: scripting question: to parse data with varname=value pattern the easiest way?

2010-11-02 Thread Zhang Weiwu, Beijing
 On 11/02/2010 05:04 AM, Karl Vogel wrote:
>On the other hand, if someone sneaks something like
>result_04: dc="3" rm /something/valuable
Thank you! very informative, and, kinda fun to read.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4ccff56c.90...@realss.com



Re: scripting question: to parse data with varname=value pattern the easiest way?

2010-11-01 Thread Karl Vogel
>> On Mon, 01 Nov 2010 15:49:01 +0800, 
>> Zhang Weiwu  said:

Z> A program output is like this:
Z>   result_01: a="23" b="288" c="A_string" ac="34"
Z>   result_02: a="23" b="28" c="A_string_too" dc="3"
Z>   

Z> I am writing a script to output values of b if b is in the result set.

   If your data is trustworthy and follows shell assignment rules like the
   example above, you can abuse sh/ksh/bash:

 #!/bin/bash

 sample='result_01: a="23" b="288" c="A_string" ac="34"
 result_02: a="23" c="A_string_too" dc="3"
 result_03: a="23" b="28" c="A_string_too" dc="3"'

 echo "$sample" | while read str
 do
 unset b   # or whatever you're looking for
 set $str  # will fail horribly if $str is empty
 result=$1
 shift
 eval "$@"
 test "$b" && echo "$result $b"
 done
 exit 0

   On the other hand, if someone sneaks something like
   result_04: dc="3" rm /something/valuable

   into your program output, you'll get a nasty surprise.

-- 
Karl Vogel  I don't speak for the USAF or my company

Most users (myself included) spend most of their time in front of a computer
in a kind of fuzzy autopilot mode, and anything that creates ripples on that
placid lake of unawareness is going to be noticed as a disproportionately
significant problem. --David Harris, creator of Pegasus Mail


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20101101210436.50fccb...@kev.msw.wpafb.af.mil



Re: scripting question

2009-07-02 Thread Marc Shapiro

Kumar Appaiah wrote:

On Wed, Jul 01, 2009 at 09:28:23AM -0500, Kumar Appaiah wrote:

for i in *zzz;do
mv "$i" $(echo "$i"|sed 's/^...//');
done

But I'd recommend one of these: mrename, krename, gprename,
renameutils and more (all apt-gettable, of course).


Oh, and I think prename (or just rename?) comes with Perl. It should
be something as simple as:

rename 's/^...//' *.zzz


Thanks, Kumar, and everyone else.  For now, rename/prename (both names 
work) does just what I need. I will look into the others when I have 
time.  I will also look at the scripts that others suggested so I can 
get more familiar with the techniques.


--
Marc Shapiro
mshapiro...@yahoo.com



--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org




Re: scripting question

2009-07-01 Thread gcrimp
On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote:
> I am sure that this is an easy question for those people who do any  
> reasonable amount of scripting.  I'm just not one of them.
>
> How can I rename all of the files ina directory with the new name being  
> the old name stripped of its leftmost three characters.  If all of the  
> files are off the format:
>
>   xxxy.zzz
>
> I want the new names to be of the format:
>
>   y.zzz
>

for file in `ls all the files` ; do mv $file ${file#xxx}; done


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: scripting question

2009-07-01 Thread Michael Ekstrand
Marc Shapiro  writes:
> I am sure that this is an easy question for those people who do any
> reasonable amount of scripting.  I'm just not one of them.
>
> How can I rename all of the files ina directory with the new name
> being the old name stripped of its leftmost three characters.  If all
> of the files are off the format:
>
>   xxxy.zzz
>
> I want the new names to be of the format:
>
>   y.zzz
>
> I have hundreds of files like this in each of several directories and
> I really don't want to do it all by hand.  I did some of that,
> already, and I know there must be a better way.

In ZSH with zmv, you can do it with the following:

$ zmv 'xxx(*).zzz' '$1.zzz'

- Michael

-- 
mouse, n: A device for pointing at the xterm in which you want to type.
Confused by the strange files?  I cryptographically sign my messages.
For more information see .


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: scripting question

2009-07-01 Thread Teemu Likonen
On 2009-07-01 18:20 (+0300), Teemu Likonen wrote:

> find -type f -print0 | xargs -0 sh -c 'for file in "$@"; 
>   do dir=$(dirname -- "$file") && base=$(basename -- "$file") &&
>   (cd "$dir" && echo mv -- "$base" "${base#???}"); done' ignore

Let's simplify it a bit:

find -type f -print0 | xargs -0 sh -c 'for file in "$@"; 
  do dir=$(dirname -- "$file") && base=$(basename -- "$file") &&
  echo mv -- "$file" "$dir/${base#???}"; done' ignore

This does it without "cd".


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: scripting question

2009-07-01 Thread Teemu Likonen
On 2009-07-01 07:22 (-0700), Marc Shapiro wrote:

> How can I rename all of the files ina directory with the new name
> being the old name stripped of its leftmost three characters. If all
> of the files are off the format:
>
>   xxxy.zzz
>
> I want the new names to be of the format:
>
>   y.zzz
>
> I have hundreds of files like this in each of several directories and
> I really don't want to do it all by hand. I did some of that, already,
> and I know there must be a better way.

Single command which affect the current directory and all
subdirectories:

find -type f -print0 | xargs -0 sh -c 'for file in "$@"; 
  do dir=$(dirname -- "$file") && base=$(basename -- "$file") &&
  (cd "$dir" && echo mv -- "$base" "${base#???}"); done' ignore

It uses "echo mv ..." command so it does nothing but echoes the command
line that would be run inside each directory. Remove the "echo" part to
actually execute the command. Of course you can add your own
file-selection options for "find" command. This works even if you have
spaces in filenames or directory names.

The command launches several processes per file so it's not terribly
elegant but should be OK for one-time rename.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: scripting question

2009-07-01 Thread Boyd Stephen Smith Jr.
In <4a4b7129.7010...@yahoo.com>, Marc Shapiro wrote:
>I am sure that this is an easy question for those people who do any
>reasonable amount of scripting.  I'm just not one of them.
>
>How can I rename all of the files ina directory with the new name being
>the old name stripped of its leftmost three characters.  If all of the
>files are off the format:
>
>   xxxy.zzz
>
>I want the new names to be of the format:
>
>   y.zzz

for f in *.zzz; do
echo mv "$f" "${f##???}"
done

If you are happy with the commands it outputs, remove the "echo".

You might also want to check for collisions first:
for f in *.zzz; do
printf '%s\n' "${f##???}"
done | sort | uniq -c | grep -v '^1 '

Should show any collisions, prefixed with a collision count.
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net  ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/



signature.asc
Description: This is a digitally signed message part.


Re: scripting question

2009-07-01 Thread Scott Gifford
Marc Shapiro  writes:


[...]

> How can I rename all of the files ina directory with the new name
> being the old name stripped of its leftmost three characters.  

My favorite way to do this is with sed and xargs.  First have sed
print the current name, then use an regexp to change it to the new
name:

ls | sed -e p -e 's/^...//' |xargs -n 2 mv

-Scott.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: scripting question

2009-07-01 Thread Kumar Appaiah
On Wed, Jul 01, 2009 at 09:28:23AM -0500, Kumar Appaiah wrote:
> On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote:
> > How can I rename all of the files ina directory with the new name
> > being the old name stripped of its leftmost three characters.  If
> > all of the files are off the format:
> > 
> > xxxy.zzz
> > 
> > I want the new names to be of the format:
> > 
> > y.zzz
> > 
> > I have hundreds of files like this in each of several directories
> > and I really don't want to do it all by hand.  I did some of that,
> > already, and I know there must be a better way.
> 
> for i in *zzz;do
> mv "$i" $(echo "$i"|sed 's/^...//');
> done
> 
> But I'd recommend one of these: mrename, krename, gprename,
> renameutils and more (all apt-gettable, of course).

Oh, and I think prename (or just rename?) comes with Perl. It should
be something as simple as:

rename 's/^...//' *.zzz

HTH.

Kumar


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: scripting question

2009-07-01 Thread Kumar Appaiah
On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote:
> How can I rename all of the files ina directory with the new name
> being the old name stripped of its leftmost three characters.  If
> all of the files are off the format:
> 
>   xxxy.zzz
> 
> I want the new names to be of the format:
> 
>   y.zzz
> 
> I have hundreds of files like this in each of several directories
> and I really don't want to do it all by hand.  I did some of that,
> already, and I know there must be a better way.

for i in *zzz;do
mv "$i" $(echo "$i"|sed 's/^...//');
done

But I'd recommend one of these: mrename, krename, gprename,
renameutils and more (all apt-gettable, of course).

HTH.

Kumar


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Re: Scripting Question - tar

2008-07-11 Thread T o n g
On Thu, 10 Jul 2008 17:04:38 -0500, Kent West wrote:

>> tar -cvzf - --one-file-system /home | split -b 2000m -

Side note since the problem has been solved. 

You might want to look into dar, which will do splitting for you
automatically, as well as many other desired features for backup
(incremental, has catalog for fast search & restore, and many many 
others...). 

 dar - Disk ARchive: Backup directory tree and files

-- 
Tong (remove underscore(s) to reply)
  http://xpt.sourceforge.net/techdocs/
  http://xpt.sourceforge.net/tools/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Scripting Question - tar

2008-07-10 Thread Kent West

Owen Townend wrote:

Kent West wrote:

 Am I just not seeing a typo somewhere? Why is my script failing?




Hey,
 You're missing the '-' for stdin

tar -czvf - --one-file-system $sourceDir | split -b 2000m - $targetFile
  


Ah, thank you!


--
Kent West   <")))><
Westing Peacefully - http://kentwest.blogspot.com


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: Scripting Question - tar

2008-07-10 Thread Owen Townend
> > tar -cvzf - --one-file-system /home | split -b 2000m -
> /TERASTATIONBACKUP/GOSHEN/2008/2008-Jul-10.tgz
vs
> > tar -czvf - --one-file-system $sourceDir | split -b 2000m $targetFile

>  Am I just not seeing a typo somewhere? Why is my script failing?
>
>  Thanks!

Hey,
 You're missing the '-' for stdin

tar -czvf - --one-file-system $sourceDir | split -b 2000m - $targetFile

:)

cheers,
Owen.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: scripting question

2008-01-06 Thread Matus UHLAR - fantomas
On 21.09.07 08:18, Michael Martinell wrote:
> My script is as follows:
> #!/bin/sh
> 
> TERM=vt100
> export TERM

forcing TERM in script is very bad idea, and in this script also useless.

> date && echo " Spam Count" && /bin/more /var/log/syslog | /bin/grep -c
> 'identified spam' && echo " " && echo "Clean Message Count " &&  /bin/more
> /var/log/syslog | /bin/grep -c 'clean message'

date

echo -n "Spam Count "
grep -Fc 'identified spam' /var/log/syslog

echo -n "Ham Count "
grep -Fc 'clean message' /var/log/syslog

... easier to read

-- 
Matus UHLAR - fantomas, [EMAIL PROTECTED] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
"They say when you play that M$ CD backward you can hear satanic messages."
"That's nothing. If you play it forward it will install Windows."


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: scripting question

2007-09-22 Thread Jude DaShiell
One possible approach would be to use a few files and use paste on those 
files where:

dfile holds date,
mfile holds good messages,
sfile holds spam messages
tfile is temporary file

paste dfile mfile >tfile
paste tfile sfile >dfile
rm mfile
rm sfile
rm tfile
cat dfile

hth.






--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: scripting question

2007-09-21 Thread Peter Teunissen


On 21-sep-2007, at 15:51, Michael Martinell wrote:


Thanks - that was exactly what I was looking for.

Now I just need to find a good scripting tutorial.  :)



Try http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html

That's where I learned my scripting basics.


Peter


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




RE: scripting question

2007-09-21 Thread Michael Martinell
Thanks - that was exactly what I was looking for.

Now I just need to find a good scripting tutorial.  :)

-Original Message-
From: Michael Marsh [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 21, 2007 8:38 AM
To: debian-user@lists.debian.org
Subject: Re: scripting question

On 9/21/07, Michael Martinell <[EMAIL PROTECTED]> wrote:
> I have a simple script that counts up the number of spam messages each day
> and prints the total number into a text field.  This is fine as far as it
> goes, however I would like to also include the date and the number of
> non-spam messages.
>
> I can get this to run, however each piece of information is printed on
it's
> own line.  I would like to have all of the results append in my text file
on
> the same line so that I can easily import it into a spreadsheet or
database.
>
> How would I go about doing this?
>
> My script is as follows:
...
> date && echo " Spam Count" && /bin/more /var/log/syslog | /bin/grep -c
> 'identified spam' && echo " " && echo "Clean Message Count " &&  /bin/more
> /var/log/syslog | /bin/grep -c 'clean message'

You can concatenate things in a single echo simply by passing multiple
arguments.  Slinging a few backticks, and you can do something like:

echo `date` " dollar signs: " `grep -c \$ ~/.bashrc` " comments: "
`grep -c \# ~/.bashrc`

Put the file name in a variable, and it should be even simpler.

-- 
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
http://36pints.blogspot.com


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: scripting question

2007-09-21 Thread Michael Marsh
On 9/21/07, Michael Martinell <[EMAIL PROTECTED]> wrote:
> I have a simple script that counts up the number of spam messages each day
> and prints the total number into a text field.  This is fine as far as it
> goes, however I would like to also include the date and the number of
> non-spam messages.
>
> I can get this to run, however each piece of information is printed on it's
> own line.  I would like to have all of the results append in my text file on
> the same line so that I can easily import it into a spreadsheet or database.
>
> How would I go about doing this?
>
> My script is as follows:
...
> date && echo " Spam Count" && /bin/more /var/log/syslog | /bin/grep -c
> 'identified spam' && echo " " && echo "Clean Message Count " &&  /bin/more
> /var/log/syslog | /bin/grep -c 'clean message'

You can concatenate things in a single echo simply by passing multiple
arguments.  Slinging a few backticks, and you can do something like:

echo `date` " dollar signs: " `grep -c \$ ~/.bashrc` " comments: "
`grep -c \# ~/.bashrc`

Put the file name in a variable, and it should be even simpler.

-- 
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
http://36pints.blogspot.com


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: scripting question

2007-09-21 Thread Neil Watson

Man echo reveals that the -n switch prevents echo from appending a new
line.  Also, you do not need to use more (or less) with grep.  Grep can
take a file agrument.  Refer to grep's man page for more information.

--
Neil Watson | Debian Linux
System Administrator| Uptime 6 days
http://watson-wilson.ca


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: Scripting question

2006-06-20 Thread Zane Dodson
Hello Anil,

On Tue, Jun 20, 2006 at 03:36:49PM +0530, Anil Gupte wrote:
| OK, I figured out the problem, but not the solution.  The output is 
| actually from a SQL query.  The output looks like this (when echoed):
| 
| Serial_Number
| TLO03
| 
| It is getting the field name and the field value as two lines. So there is 
| a newline before the TLO03 not a space.  So I tried 
| Serial_Number=${Serial_Number#\n} and Serial_Number=${Serial_Number#\r} but 
| neither seemed to work.  Any suggestions?

Perhaps there are additional characters in the output you cannot
see.

Try
  % echo -nE "${Serial_Number}" | od -c

Note also that word splitting occurs (using IFS) if you leave off
the double quotes (in the echo command but not in variable
assignment).  (Try the above echo command without the double quotes
and notice the result.)  See the EXPANSION section of the Bash man
page for a discussion of the order of expansions.  The sections on
PARAMETERS and Word Splitting might also prove helpful.

| In fact a better thing would be to get the result from mysql without the 
| field name - just the value as a string.  Any ideas how?

Perhaps using -B (tab-delimited output) and -N (suppress column
header line) would help.

Best regards,

-- 
Zane Dodson


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Scripting question

2006-06-20 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Anil Gupte wrote:
> OK, I figured out the problem, but not the solution.  The output
> is actually from a SQL query.  The output looks like this (when
> echoed):
> 
> Serial_Number TLO03
> 
> It is getting the field name and the field value as two lines. So
> there is a newline before the TLO03 not a space.  So I tried 
> Serial_Number=${Serial_Number#\n} and
> Serial_Number=${Serial_Number#\r} but neither seemed to work.
> Any suggestions?
> 
> In fact a better thing would be to get the result from mysql
> without the field name - just the value as a string.  Any ideas
> how?

A stored procedure?  (Does MySQL have stored procedures?)

- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEl+P8S9HxQb37XmcRAiU+AJ93zdBGis1Urv4awbEALyoX+Pkf3QCg2a8I
ZQRdejZBq/4bNG/ZHo9QWyE=
=ioIY
-END PGP SIGNATURE-


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Scripting question

2006-06-20 Thread Nyizsnyik Ferenc
On Tue, 2006-06-20 at 15:36 +0530, Anil Gupte wrote:
> OK, I figured out the problem, but not the solution.  The output is actually 
> from a SQL query.  The output looks like this (when echoed):
> 
> Serial_Number
> TLO03
> 
> It is getting the field name and the field value as two lines. So there is a 
> newline before the TLO03 not a space.  So I tried 
> Serial_Number=${Serial_Number#\n} and Serial_Number=${Serial_Number#\r} but 
> neither seemed to work.  Any suggestions?
> 
> In fact a better thing would be to get the result from mysql without the 
> field 
> name - just the value as a string.  Any ideas how?
> 
> Thanx again.
> Anil Gupte

If this is the only output, you may try this:
 |grep -v Serial_Number

Or this:
 --disable-column-names

> www.keeninc.net
> www.icinema.com
> 
> - Original Message - 
> From: "Hal Vaughan" <[EMAIL PROTECTED]>
> To: 
> Sent: Monday, June 19, 2006 11:00 PM
> Subject: Re: Scripting question
> 
> 
> > On Monday 19 June 2006 13:00, Anil Gupte wrote:
> >> Why does
> >>
> >> echo /l3dat/${Serial_Nuumber}.tar.gz
> >>
> >> give me
> >>
> >> /l3dat/ TLO3.tar.gz
> >>
> >> In other words, why is it putting an etra space in there (after the
> >> second /) and how can I get rid of it?
> >>
> >> And yes, there is no space there.  I checked by using
> >>
> >> Serial_Number=${Serial_Number##" "}
> >
> > Have you tried concatenating two strings?  Starting with:
> >
> > tdir=/l3dat/
> > tfile=${Serial_Number}.tar.gz
> >
> > then concatenated them?
> >
> > If that works, great, if you still get a leading space on tfile, try:
> >
> > tfile=${tfile# }
> >
> > AFTER you've set $tfile.  It's a regex that will eliminate a leading
> > space.
> >
> > Hal
> >
> >
> > -- 
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> >
> > 
> 
> 
-- 
Szia:
Nyizsa.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Scripting question

2006-06-20 Thread Anil Gupte
OK, I figured out the problem, but not the solution.  The output is actually 
from a SQL query.  The output looks like this (when echoed):


Serial_Number
TLO03

It is getting the field name and the field value as two lines. So there is a 
newline before the TLO03 not a space.  So I tried 
Serial_Number=${Serial_Number#\n} and Serial_Number=${Serial_Number#\r} but 
neither seemed to work.  Any suggestions?


In fact a better thing would be to get the result from mysql without the field 
name - just the value as a string.  Any ideas how?


Thanx again.
Anil Gupte
www.keeninc.net
www.icinema.com

- Original Message - 
From: "Hal Vaughan" <[EMAIL PROTECTED]>

To: 
Sent: Monday, June 19, 2006 11:00 PM
Subject: Re: Scripting question



On Monday 19 June 2006 13:00, Anil Gupte wrote:

Why does

echo /l3dat/${Serial_Nuumber}.tar.gz

give me

/l3dat/ TLO3.tar.gz

In other words, why is it putting an etra space in there (after the
second /) and how can I get rid of it?

And yes, there is no space there.  I checked by using

Serial_Number=${Serial_Number##" "}


Have you tried concatenating two strings?  Starting with:

tdir=/l3dat/
tfile=${Serial_Number}.tar.gz

then concatenated them?

If that works, great, if you still get a leading space on tfile, try:

tfile=${tfile# }

AFTER you've set $tfile.  It's a regex that will eliminate a leading
space.

Hal


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]





--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: Scripting question

2006-06-19 Thread Hal Vaughan
On Monday 19 June 2006 13:00, Anil Gupte wrote:
> Why does
>
> echo /l3dat/${Serial_Nuumber}.tar.gz
>
> give me
>
> /l3dat/ TLO3.tar.gz
>
> In other words, why is it putting an etra space in there (after the
> second /) and how can I get rid of it?
>
> And yes, there is no space there.  I checked by using
>
> Serial_Number=${Serial_Number##" "}

Have you tried concatenating two strings?  Starting with:

tdir=/l3dat/
tfile=${Serial_Number}.tar.gz

then concatenated them?

If that works, great, if you still get a leading space on tfile, try:

tfile=${tfile# }

AFTER you've set $tfile.  It's a regex that will eliminate a leading 
space. 

Hal


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Scripting question

2006-06-19 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Anil Gupte wrote:
> Why does
> 
> echo /l3dat/${Serial_Nuumber}.tar.gz
> 
> give me
> 
> /l3dat/ TLO3.tar.gz
> 
> In other words, why is it putting an etra space in there (after
> the second /) and how can I get rid of it?
> 
> And yes, there is no space there.  I checked by using
> 
> Serial_Number=${Serial_Number##" "}
> 
> and the variable prints the same before and after.
> 
> Thanx in advance for any help. Anil Gupte

Are you sure there isn't a subtle data error somewhere?

$ bash --version
GNU bash, version 3.1.14(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

$ Serial_Nuumber=TLO3

$ echo /l3dat/${Serial_Nuumber}.tar.gz
/l3dat/TLO3.tar.gz

P.S. - Please don't hijack existing threads.

- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEltr8S9HxQb37XmcRAmUtAKDEAbW/kMpbRm8fjLINJypWTeenRgCgxf+e
5iIRu9T8mfF1aAnG1fSkxIE=
=ECKD
-END PGP SIGNATURE-


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Scripting question

2006-06-19 Thread Zane Dodson
Hello Anil,

On Mon, Jun 19, 2006 at 10:30:16PM +0530, Anil Gupte wrote:
| Why does
| 
| echo /l3dat/${Serial_Nuumber}.tar.gz
^^ Is this a typo?
| 
| give me
| 
| /l3dat/ TLO3.tar.gz
| 
| Serial_Number=${Serial_Number##" "}
| 
| and the variable prints the same before and after.

Try

 % echo "\`${Serial_Number}'"

and examine the output for leading spaces.

Best regards,

-- 
Zane Dodson


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]