I say this from a FreeBSD context. It may entirely be possible that a
Linux distro uses bash in /bin/sh
Yes. For most (all?) linux distros as well as osx, /bin/sh is actually
bash. When I say "emulation mode" I mean running a script with a
"#!/bin/sh" header on a system that doesn't have a rea
On May 18, 2013, at 5:06 PM, Teske, Devin wrote:
>
> On May 18, 2013, at 4:54 PM, Quartz wrote:
>
>>
>>> #foo works with sh
>>
>> Is it actually part of the official spec though is what I'm wondering, or is
>> it a case of other shells not rejecting 'advanced' statements when running
>> in
On May 18, 2013, at 4:54 PM, Quartz wrote:
>
>> #foo works with sh
>
> Is it actually part of the official spec though is what I'm wondering, or is
> it a case of other shells not rejecting 'advanced' statements when running in
> emulation.
>
Shells don't have an "emulation mode". The shell
By default, there is no bash on FreeBSD,
Right right... I know this, but forgot what list I was on :)
It doesn't help that I always install bash first thing on any freebsd
box or it get's installed automatically as part of pc-bsd anyway.
__
it has a certai
#foo works with sh
Is it actually part of the official spec though is what I'm wondering,
or is it a case of other shells not rejecting 'advanced' statements when
running in emulation.
At least FreeBSD's implementation of sh (which is ash, I think)
supports the # functionality.
The rea
On May 18, 2013, at 9:06 AM, Polytropon wrote:
> On Sat, 18 May 2013 11:58:30 -0400, Quartz wrote:
>>
newfoo=${foo:0:51}
>>>
>>> That works for bash, not sh.
>>
>> Ok granted, but I don't think that ${#foo} is straight sh either, so I
>> assumed "things bash/tcsh/ksh/whatever accep
On Sat, 18 May 2013 11:58:30 -0400, Quartz wrote:
>
> >> newfoo=${foo:0:51}
> >>
> >
> > That works for bash, not sh.
>
> Ok granted, but I don't think that ${#foo} is straight sh either, so I
> assumed "things bash/tcsh/ksh/whatever accept when running in sh
> emulation" were ok.
By default,
#foo works with sh
On May 18, 2013 10:58:30 AM Quartz wrote:
>> newfoo=${foo:0:51}
>>
>
> That works for bash, not sh.
Ok granted, but I don't think that ${#foo} is straight sh either, so I
assumed "things bash/tcsh/ksh/whatever accept when running in sh emulation"
were ok.
newfoo=${foo:0:51}
That works for bash, not sh.
Ok granted, but I don't think that ${#foo} is straight sh either, so I
assumed "things bash/tcsh/ksh/whatever accept when running in sh
emulation" were ok.
__
it has a certain smooth-brained appeal
_
However, if the OP wanted to actually truncate $FOO to 51
characters:
NEWFOO=$( echo "$FOO" | awk -v max=51 '{print substr($0,0,max)}' )
You don't need all that for a simple truncation/substring, you can do it
with a direct assignment:
newfoo=${foo:0:51}
The three params here are "variabl
On 05/18/2013 10:09 AM, Quartz wrote:
However, if the OP wanted to actually truncate $FOO to 51
characters:
NEWFOO=$( echo "$FOO" | awk -v max=51 '{print substr($0,0,max)}' )
You don't need all that for a simple truncation/substring, you can do it with a
direct assignment:
newfoo=${foo:0:5
On May 16, 2013, at 9:27 AM, Teske, Devin wrote:
On May 16, 2013, at 9:06 AM, Teske, Devin wrote:
On May 16, 2013, at 8:28 AM, Tim Daneliuk wrote:
On 05/16/2013 10:08 AM, Joe wrote:
Hello
Have script that has max size on content in a variable.
How to code size less than 51 characters?
FOO=
On May 16, 2013, at 9:06 AM, Teske, Devin wrote:
>
> On May 16, 2013, at 8:28 AM, Tim Daneliuk wrote:
>
>> On 05/16/2013 10:08 AM, Joe wrote:
>>> Hello
>>>
>>> Have script that has max size on content in a variable.
>>> How to code size less than 51 characters?
>>>
>>
>> FOO="Some string you
On 05/16/2013 10:45 AM, Dan Nelson wrote:
In the last episode (May 16), Tim Daneliuk said:
On 05/16/2013 10:08 AM, Joe wrote:
Hello
Have script that has max size on content in a variable.
How to code size less than 51 characters?
FOO="Some string you want to check length of"
FOOLEN=`echo $F
On May 16, 2013, at 8:28 AM, Tim Daneliuk wrote:
> On 05/16/2013 10:08 AM, Joe wrote:
>> Hello
>>
>> Have script that has max size on content in a variable.
>> How to code size less than 51 characters?
>>
>
> FOO="Some string you want to check length of"
> FOOLEN=`echo $FOO | wc | awk '{print
something like this:
#!/bin/sh
if [ $# -lt 1 ] ; then
echo "put a nickel in the slot, pal!"
exit 1;
fi
NUMCHARS=`echo $1 | wc -m`
if [ $NUMCHARS -lt 51 ] ; then
echo "You input "$NUMCHARS" characters."
exit 0
else
echo "whoa sailor I can't take all that!"
exit 1
fi
On 13-05-16 9:08 AM, Joe wrote
In the last episode (May 16), Tim Daneliuk said:
> On 05/16/2013 10:08 AM, Joe wrote:
> > Hello
> >
> > Have script that has max size on content in a variable.
> > How to code size less than 51 characters?
> >
>
> FOO="Some string you want to check length of"
> FOOLEN=`echo $FOO | wc | awk '{print
On 05/16/2013 10:08 AM, Joe wrote:
Hello
Have script that has max size on content in a variable.
How to code size less than 51 characters?
FOO="Some string you want to check length of"
FOOLEN=`echo $FOO | wc | awk '{print $3}'`
You can then use $FOOLEN in a conditional.
--
--
Hello
Have script that has max size on content in a variable.
How to code size less than 51 characters?
Thanks
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "
19 matches
Mail list logo