Re: bash help

2017-02-22 Thread Cameron Simpson
On 19Feb2017 05:22, Mike Wright wrote: My brain cell ran away from home. I have an incredibly simple script that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm trying to put it in a script: "~/bin/mdcd". After checking that $1 exists: dir="$1" mkdir -p "$dir" cd "$dir"

Re: [OT] bash help

2017-02-20 Thread Jon LaBadie
On Mon, Feb 20, 2017 at 10:46:23AM +, Andy Blanchard wrote: > On 20 February 2017 at 09:18, T_POL wrote: > > > > not sure about that but I think the "cd" command executes indeed > > but it's valid only for the scripts' environment and not for the > > shell you started the script from. > > *di

Re: [OT] bash help

2017-02-20 Thread Andy Blanchard
On 20 February 2017 at 09:18, T_POL wrote: > > not sure about that but I think the "cd" command executes indeed > but it's valid only for the scripts' environment and not for the > shell you started the script from. *ding* *ding* *ding* We have a winner! Shells execute in their own instance of

Re: [OT] bash help

2017-02-20 Thread T_POL
On Sun, 19 Feb 2017 05:22:44 -0800 Mike Wright wrote: > Hi all, > > My brain cell ran away from home. I have an incredibly simple script > that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm > trying to put it in a script: "~/bin/mdcd". > > After checking that $1 exists: >

Re: [OT] bash help

2017-02-20 Thread Dave Mitchell
On Sun, Feb 19, 2017 at 02:12:35PM -0800, Joe Zeff wrote: > On 02/19/2017 05:22 AM, Mike Wright wrote: > > dir="$1" > > mkdir -p "$dir" > > cd "$dir" <-- never executes > I'm not sure why this doesn't work but you're doing it the hard way. > > mkdir -p $1 > cd $1 > > is much simpler, and

Re: [OT] bash help

2017-02-19 Thread Mike Wright
On 02/19/2017 03:46 PM, Patrick O'Callaghan wrote: On Sun, 2017-02-19 at 05:22 -0800, Mike Wright wrote: Hi all, My brain cell ran away from home. I have an incredibly simple script that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm trying to put it in a script: "~/bin/mdcd

Re: [OT] bash help

2017-02-19 Thread Patrick O'Callaghan
On Sun, 2017-02-19 at 05:22 -0800, Mike Wright wrote: > Hi all, > > My brain cell ran away from home. I have an incredibly simple script > that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm > trying to put it in a script: "~/bin/mdcd". > > After checking that $1 exists: >

Re: [OT] bash help

2017-02-19 Thread Robert Nichols
On 02/19/2017 07:22 AM, Mike Wright wrote: Hi all, My brain cell ran away from home. I have an incredibly simple script that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm trying to put it in a script: "~/bin/mdcd". After checking that $1 exists: dir="$1" mkdir -p "$dir"

Re: [OT] bash help

2017-02-19 Thread Joe Zeff
On 02/19/2017 05:22 AM, Mike Wright wrote: Hi all, My brain cell ran away from home. I have an incredibly simple script that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm trying to put it in a script: "~/bin/mdcd". After checking that $1 exists: dir="$1" mkdir -p "$dir" cd

[OT] bash help

2017-02-19 Thread Mike Wright
Hi all, My brain cell ran away from home. I have an incredibly simple script that doesn't do what I expect. I use "mkdir DIR; cd DIR" a lot so I'm trying to put it in a script: "~/bin/mdcd". After checking that $1 exists: dir="$1" mkdir -p "$dir" cd "$dir" <-- never executes The dir

Re: OT: bash help

2014-08-17 Thread Ian Malone
On 17 August 2014 08:36, Cameron Simpson wrote: > On 16Aug2014 14:44, Mike Wright wrote: >> >> I'm trying to write a simple script that if provided an argument, uses >> that, or if nothing is provided, uses a predefined string. > > > This is general shell stuff, not bash specific. > >> if [ -n $#

Re: OT: bash help

2014-08-17 Thread Cameron Simpson
On 16Aug2014 14:44, Mike Wright wrote: I'm trying to write a simple script that if provided an argument, uses that, or if nothing is provided, uses a predefined string. This is general shell stuff, not bash specific. if [ -n $# ] This is always true. Even "0" is a nonempty string. Test [

Re: OT: bash help

2014-08-16 Thread Mike Wright
08/16/2014 04:14 PM, Mark C. Allman wrote: On Sun, 2014-08-17 at 00:42 +0200, Suvayu Ali wrote: On Sat, Aug 16, 2014 at 02:44:14PM -0700, Mike Wright wrote: Hi all, I'm trying to write a simple script that if provided an argument, uses that, or if nothing is provided, uses a predefined string.

Re: OT: bash help

2014-08-16 Thread Mark C. Allman
On Sun, 2014-08-17 at 00:42 +0200, Suvayu Ali wrote: > On Sat, Aug 16, 2014 at 02:44:14PM -0700, Mike Wright wrote: > > Hi all, > > > > I'm trying to write a simple script that if provided an argument, uses that, > > or if nothing is provided, uses a predefined string. > > > > if [ -n $# ] > > T

Re: OT: bash help

2014-08-16 Thread Suvayu Ali
On Sat, Aug 16, 2014 at 02:44:14PM -0700, Mike Wright wrote: > Hi all, > > I'm trying to write a simple script that if provided an argument, uses that, > or if nothing is provided, uses a predefined string. > > if [ -n $# ] This will always be true. -n tests if a string is empty or not. 0 coun

Re: OT: bash help

2014-08-16 Thread Joe Zeff
On 08/16/2014 02:44 PM, Mike Wright wrote: I'm trying to write a simple script that if provided an argument, uses that, or if nothing is provided, uses a predefined string. I found this example that might help: http://tldp.org/LDP/abs/html/comparison-ops.html#STRTEST -- users mailing list use

Re: OT: bash help

2014-08-16 Thread Fred Smith
On Sat, Aug 16, 2014 at 02:44:14PM -0700, Mike Wright wrote: > Hi all, > > I'm trying to write a simple script that if provided an argument, > uses that, or if nothing is provided, uses a predefined string. > > if [ -n $# ] > then > WORDS=$1 > else > WORDS="these are some words" > fi > ec

Re: OT: bash help

2014-08-16 Thread Joe Zeff
On 08/16/2014 02:44 PM, Mike Wright wrote: if [ -n $# ] then WORDS=$1 else WORDS="these are some words" fi echo $WORDS; The second case is always comes back "". But if I write WORDS='these are some words' echo $WORDS I get the assigned string. In your first example, you use full q

OT: bash help

2014-08-16 Thread Mike Wright
Hi all, I'm trying to write a simple script that if provided an argument, uses that, or if nothing is provided, uses a predefined string. if [ -n $# ] then WORDS=$1 else WORDS="these are some words" fi echo $WORDS; The second case is always comes back "". But if I write WORDS='these

Re: OT: bash help

2013-07-11 Thread Cameron Simpson
On 07Jul2013 20:38, Ian Malone wrote: | On 7 July 2013 20:18, Mike Wright wrote: | >>> I'm trying to write a bash command to transcode some videos into audios | >>> but am having trouble with filenames that contain spaces. | >>> | >>> ls *flv | >>> | >>> returns this: | >>> | >>> Jorge Drexler -

Re: OT: bash help

2013-07-07 Thread Dave Ihnat
Once, long ago--actually, on Sun, Jul 07, 2013 at 02:18:16PM CDT--Mike Wright (mike.wri...@mailinator.com) said: > exactly what I needed. I'd never discovered IFS before As you've discovered, it's quite useful to manipulate IFS. Just a suggestion, however. In scripts where you modify IFS, do s

Re: OT: bash help

2013-07-07 Thread Garry T. Williams
On 7-7-13 11:29:05 Mike Wright wrote: > I'm trying to write a bash command to transcode some videos into audios > but am having trouble with filenames that contain spaces. > > ls *flv > > returns this: > > Jorge Drexler - Al otro Lado del Río.flv > > But in a bash for loop it doesn't work. >

Re: OT: bash help

2013-07-07 Thread Ian Malone
On 7 July 2013 20:18, Mike Wright wrote: > 07/07/2013 12:03 PM, Steve Searle wrote: >> >> Around 07:29pm on Sunday, July 07, 2013 (UK time), Mike Wright scrawled: >> >>> I'm trying to write a bash command to transcode some videos into audios >>> but am having trouble with filenames that contain sp

Re: OT: bash help

2013-07-07 Thread Mike Wright
07/07/2013 12:03 PM, Steve Searle wrote: Around 07:29pm on Sunday, July 07, 2013 (UK time), Mike Wright scrawled: I'm trying to write a bash command to transcode some videos into audios but am having trouble with filenames that contain spaces. ls *flv returns this: Jorge Drexler - Al otro La

Re: OT: bash help

2013-07-07 Thread Steve Searle
Around 07:29pm on Sunday, July 07, 2013 (UK time), Mike Wright scrawled: > I'm trying to write a bash command to transcode some videos into audios > but am having trouble with filenames that contain spaces. > > ls *flv > > returns this: > > Jorge Drexler - Al otro Lado del Río.flv > > But in

OT: bash help

2013-07-07 Thread Mike Wright
Hi all, I'm trying to write a bash command to transcode some videos into audios but am having trouble with filenames that contain spaces. ls *flv returns this: Jorge Drexler - Al otro Lado del Río.flv But in a bash for loop it doesn't work. for f in `ls *flv`; do echo $f; done returns th

Re: OT: need bash help

2011-10-17 Thread g
On 10/17/2011 07:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. you seem to have several replies that can give you what you want. here are a couple links that i have found helpful; http://tldp.org/LDP/abs/html/ http://www.faqs.org/docs/abs/HTM

Re: OT: need bash help [solved]

2011-10-17 Thread Ian Malone
On 17 October 2011 20:45, Mike Wright wrote: > On 10/17/2011 12:39 PM, Mike Wright wrote: >> Hi all, >> >> I'm trying to write a bash script and having problems. >> >> If I execute this: >> >>     ps x | grep mongod | wc -l >> >> it returns a value. >> >> OTOH, if I execute this: >> >>     LINES =

Re: OT: need bash help [solved]

2011-10-17 Thread Pete Travis
Backticks for a subshell are 'depricated' though the convention is still in wide use. I use the $() method because `su - user 'command --opt="foo"'` and such can get a bit confusing, and the alternative is much easier to pick out of a mass of text. On Oct 17, 2011 1:45 PM, "Mike Wright" wrote:

Re: OT: need bash help

2011-10-17 Thread Pete Travis
Try wrapping your command to make a subshell: LINES=$(ps x| grep mongod | wc -l) HTH, Pete On Oct 17, 2011 1:39 PM, "Mike Wright" wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > > ps x | grep mongod | wc -l > > it returns a value. > > OTOH

Re: OT: need bash help

2011-10-17 Thread Emmett Culley
On 10/17/2011 12:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > > ps x | grep mongod | wc -l > > it returns a value. > > OTOH, if I execute this: > > LINES = ps x | grep mongod | wc -l > > it returns "command no

Re: OT: need bash help [solved]

2011-10-17 Thread Mike Wright
On 10/17/2011 12:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > > ps x | grep mongod | wc -l > > it returns a value. > > OTOH, if I execute this: > > LINES = ps x | grep mongod | wc -l > > it returns "command not found

Re: OT: need bash help

2011-10-17 Thread Larry Brower
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 10/17/2011 02:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > >ps x | grep mongod | wc -l > > it returns a value. > > OTOH, if I execute this: > >LINES = ps x |

OT: need bash help

2011-10-17 Thread Mike Wright
Hi all, I'm trying to write a bash script and having problems. If I execute this: ps x | grep mongod | wc -l it returns a value. OTOH, if I execute this: LINES = ps x | grep mongod | wc -l it returns "command not found". How does one assign the output of a command to an environment va