On 09/20/2012 04:29, Polytropon wrote:
Correct. You could use different approaches which may or may
not fail due to the directory names you will encounter (like
directories with spaces or special characters).
#!/bin/sh
for DIR in `ls -LF | grep \/`; do
cd ${DIR}
Many thanks! The for loop was what was needed.
Polytropon writes:
Just a sidenote: If you're not using bash-specific functionality
and intend to make your script portable, use #!/bin/sh instead.
I always start out that way for that very reason. I needed some
random number functions and
On Thu, 20 Sep 2012 11:16:40 +0200, Jan Henrik Sylvester wrote:
On 09/20/2012 04:29, Polytropon wrote:
Correct. You could use different approaches which may or may
not fail due to the directory names you will encounter (like
directories with spaces or special characters).
#!/bin/sh
I just discovered a knowledge deficiency on my part that
I can't seem to resolve.
If one writes a loop of the following form:
#!/usr/local/bin/bash
ls -LF |grep \/ /tmp/files
while read dirname; do
cd $dirname
#Do whatever commands to be repeated in each directory.
done
On Wed, 19 Sep 2012 21:03:11 -0500 Martin McCormick wrote:
#!/usr/local/bin/bash
ls -LF |grep \/ /tmp/files
while read dirname; do
cd $dirname
#Do whatever commands to be repeated in each directory.
done /tmp/files
How about:
ls -LF | grep \/ | while read dirname; do
cd $dirname
On Wed, 19 Sep 2012 21:03:11 -0500, Martin McCormick wrote:
I just discovered a knowledge deficiency on my part that
I can't seem to resolve.
If one writes a loop of the following form:
#!/usr/local/bin/bash
Just a sidenote: If you're not using bash-specific functionality
and
Nerius Landys nlan...@gmail.com wrote:
Is there a function, or command line utility, to escape a string,
making it suitable to be input on the command line? For example, this
escape utility would take a input of te st and create an output of
te\ st. Other things such as quotes and single
On 15.02.2010 09:21, Nerius Landys wrote:
But in the case where you're assigning the output of ls directly to a
variable like this:
FOO=`ls`
vs
FOO=`ls`
the text assigned to FOO is the same, right?
Apparently, it is:
sh-4.0$ touch x *
sh-4.0$ FOO=`ls`;echo $FOO|od
000 020170
Nerius Landys nlan...@gmail.com wrote:
#!/bin/sh
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
What if I got rid of extra double quotes? Like this:
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
That is perfectly fine. Word-splitting and filename expansion are
not
#!/bin/sh
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
What if I got rid of extra double quotes? Like this:
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
That is perfectly fine. Word-splitting and filename expansion are
not performed for variable assignments. Also
#!/bin/sh
I have these lines in my script:
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
What if I got rid of extra double quotes? Like this:
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
Does this behave any differently in any kind of case? Are thes double
quotes just
On 15.02.2010 08:07, Nerius Landys wrote:
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
What if I got rid of extra double quotes? Like this:
DIRNAME=`dirname \$0\`
cd $DIRNAME
SCRIPTDIR=`pwd`
Does this behave any differently in any kind of case? Are thes double
quotes just
From the man page:
Command Substitution
[...]
If the substitution appears within double quotes, word splitting and
pathname expansion are not performed on the results.
In other words:
sh-4.0$ touch x y
sh-4.0$ for i in `ls`; do echo $i; done
x
y
sh-4.0$ for i in `ls`; do
Paul Schmehl wrote:
I could do this in perl easily, but I'm trying to force myself to learn
shell scripting better. :-)
...
Once this file is created (or ideally *while* it's being created!) I
need to increment the sid numbers. The first one is 201. The
second needs to be 202,
I could do this in perl easily, but I'm trying to force myself to learn shell
scripting better. :-)
I'm parsing a file to extract some elements from it, then writing the results,
embeded in long strings, into an output file.
Here's the script:
cat file.1 | cut -d',' -f9 | sort | uniq
At 11:35 AM 2/19/2008, Paul Schmehl wrote:
I could do this in perl easily, but I'm trying to force myself to learn
shell scripting better. :-)
I'm parsing a file to extract some elements from it, then writing the
results, embeded in long strings, into an output file.
Here's the script:
Paul Schmehl wrote:
I could do this in perl easily, but I'm trying to force myself to learn
shell scripting better. :-)
I'm parsing a file to extract some elements from it, then writing the
results, embeded in long strings, into an output file.
Here's the script:
cat file.1 | cut
--On Tuesday, February 19, 2008 12:41:43 -0600 Derek Ragona
[EMAIL PROTECTED] wrote:
Thanks to all who offered suggestions. Here's a working script that creates
snort rules *and* a sid-msg.map file:
#!/bin/sh
cat file.1 | cut -d',' -f9 | sort | uniq file.nicks
i=202
j=`wc -l
Eric Crist wrote:
First off, I don't care if you send example in perl, php, or sh, but
we're not a python shop here, so those recommendation will not be
useful...
I'm trying to write a shell script that scans our databases for
tables starting with archive_ which are created by other
Hey all,
First off, I don't care if you send example in perl, php, or sh, but
we're not a python shop here, so those recommendation will not be
useful...
I'm trying to write a shell script that scans our databases for
tables starting with archive_ which are created by other scripts/
Eric Crist wrote:
Hey all,
First off, I don't care if you send example in perl, php, or sh, but
we're not a python shop here, so those recommendation will not be
useful...
I'm trying to write a shell script that scans our databases for tables
starting with archive_ which are created by
On Mon, 10 Apr 2006, Malcolm Fitzgerald wrote:
On 10/04/2006, at 12:39 AM, Jan Grant wrote:
On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:
I'm trying to follow the instructions at
http://www.daemonology.net/freebsd-upgrade-5.4-to-6.0/
Your advice got me to step 7 where the need
I'm trying to follow the instructions at
http://www.daemonology.net/freebsd-upgrade-5.4-to-6.0/
At point four it offers this shell script.
cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
while read X; do
if [ -f $X ]; then echo $X; fi;
done | sort
On 4/9/06, Malcolm Fitzgerald [EMAIL PROTECTED] wrote:
I'm trying to follow the instructions at
http://www.daemonology.net/freebsd-upgrade-5.4-to-6.0/
At point four it offers this shell script.
cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
while read X; do
On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:
I'm trying to follow the instructions at
http://www.daemonology.net/freebsd-upgrade-5.4-to-6.0/
At point four it offers this shell script.
cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
while read X; do
On 10/04/2006, at 12:39 AM, Jan Grant wrote:
On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:
I'm trying to follow the instructions at
http://www.daemonology.net/freebsd-upgrade-5.4-to-6.0/
At point four it offers this shell script.
cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq
On 10/04/2006, at 12:39 AM, Jan Grant wrote:
On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:
I'm trying to follow the instructions at
http://www.daemonology.net/freebsd-upgrade-5.4-to-6.0/
At point four it offers this shell script.
cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq
I'm thinking about writing an rc.subr script that sucks in variables from a
conf file. Since the rc.firewall script does just that, I thought I'd take
a look at it. But I can't understand what it's doing.
Here's the code:
# Suck in the configuration variables.
if [ -z
On Mar 24, 2006, at 12:12 PM, Paul Schmehl wrote:
Neither rc.conf nor source_rc_confs appears anywhere else in the
script, so how does this suck in the variables? And what does the
syntax . /etc/rc.conf do?
Your second question is the answer to your first question:
. /etc/rc.conf
Yeah, but I am looking for 0 ... 8,9,11,14 are all in use ... but 0-7
are not. I want to:
starting with zero, find the lowest number that is NOT in this list
(where this list is the output of mdconfig -l, which shows which md
devices are currently in use)
Running mdconfig
On Wed, 25 Jan 2006, Luke Bakken wrote:
Thank you very much - you got no output because you have no md devices in
use. I have a few in use and this is the output I get:
# mdconfig -l
md3 md2 md1 md0
But I could just as easily get:
# mdconfig -l
md9 md8 md5 md3
Hmm...I
Thank you very much - you got no output because you have no md devices in
use. I have a few in use and this is the output I get:
# mdconfig -l
md3 md2 md1 md0
But I could just as easily get:
# mdconfig -l
md9 md8 md5 md3
Hmm...I just saw that that line is in
On Wed, 25 Jan 2006, Luke Bakken wrote:
#!/bin/sh
function find_first_mdevice
{
MDDEV='md0 md1 md2 md3 md4 md5 md6 md7 md8 md9'
MDOUT=`mdconfig -l`
for DEV in $MDDEV
do
if ! echo $MDOUT | grep -q $DEV
then
break
fi
done
Hello,
When I mdconfig a device and _do not_ specify a particular numbered md
device (with the -u flag), it just chooses an unused device number for
me. Which makes me happy.
Unfortunately, mdconfig chooses the next available device, from the
highest device currently in use, regardless of
Ensel Sharon wrote:
and I know how to use awk to strip away the leading md from each piece
of the output ... but I do not know how to take output like:
8 9 11 14
and decide that the lowest available number is 0. How can I do this ?
% echo '9 8 11 14' | sort -nt ' ' | head -1
8
--
-Chuck
On Tue, 24 Jan 2006, Chuck Swiger wrote:
Ensel Sharon wrote:
and I know how to use awk to strip away the leading md from each piece
of the output ... but I do not know how to take output like:
8 9 11 14
and decide that the lowest available number is 0. How can I do this ?
%
Ensel Sharon wrote:
and I know how to use awk to strip away the leading md from each piece
of the output ... but I do not know how to take output like:
8 9 11 14
and decide that the lowest available number is 0. How can I do this ?
% echo '9 8 11 14' | sort -nt ' ' | head
Luke,
On Tue, 24 Jan 2006, Luke Bakken wrote:
Yeah, but I am looking for 0 ... 8,9,11,14 are all in use ... but 0-7
are not. I want to:
starting with zero, find the lowest number that is NOT in this list
(where this list is the output of mdconfig -l, which shows which md
devices
I've written a script to check apache to make sure it's running *and*
logging. One of the variables I create is named DATEHOUR, and it's created
by parsing the output of date in such a way that all I get is the hour
(using awk and cut.) I'm comparing DATEHOUR to LOGHOUR, which represents
the
To get the date in the right format you could simply use
date +%H
Greetz,
Ice
Paul Schmehl schrieb:
I've written a script to check apache to make sure it's running *and*
logging. One of the variables I create is named DATEHOUR, and it's
created by parsing the output of date in such a way
--On Monday, September 12, 2005 20:37:22 +0200 Frank Mueller - emendis GmbH
[EMAIL PROTECTED] wrote:
To get the date in the right format you could simply use
date +%H
That solves one-half of the problem. I would still have to get the hour
from the file into the correct format. Otherwise
On 9/12/05, Paul Schmehl [EMAIL PROTECTED] wrote:
How can I strip the leading character from the string so that I can test to
see if it's zero?
This'll strip the 0, while leaving other numbers intact:
$ X=09
$ echo ${X#0}
9
___
--On Monday, September 12, 2005 13:17:05 -0700 David Kirchner [EMAIL PROTECTED]
wrote:
On 9/12/05, Paul Schmehl [EMAIL PROTECTED] wrote:
How can I strip the leading character from the string so that I can test
to see if it's zero?
This'll strip the 0, while leaving other numbers intact:
$
43 matches
Mail list logo