How long can a bash command line be? - Setup

This is a discussion on How long can a bash command line be? - Setup ; I want to chain a like of commands usin the &&. What is the maximum length allowed - can it be user defined through some option?...

+ Reply to Thread
Results 1 to 8 of 8

Thread: How long can a bash command line be?

  1. How long can a bash command line be?


    I want to chain a like of commands usin the &&. What is the maximum
    length allowed - can it be user defined through some option?


  2. Re: How long can a bash command line be?

    voipfc wrote:
    > I want to chain a like of commands usin the &&. What is the maximum
    > length allowed - can it be user defined through some option?


    End a command line with \ and bash will continue reading the next line
    as though it were all one line. I have not come across a limit in the
    number of lines that can be "concatenated" this way.

  3. Re: How long can a bash command line be?

    In article <1164926853.966833.298300@f1g2000cwa.googlegroups.c om>,
    voipfc wrote:
    >
    > I want to chain a like of commands usin the &&. What is the maximum
    > length allowed - can it be user defined through some option?


    IIRC the limit is something like 20KB. Don't know how you find out. I
    guess try longer ones until it breaks. How long were you thinking? If
    you have to split it, then for parts 2-n tack on "[ $? = 0 ] &&" to more
    conditions. Or just have your code's logic not build them when they're
    not needed.

    --
    -eben QebWenE01R@vTerYizUonI.nOetP royalty.no-ip.org:81
    A: Because it looks dumb and is hard to read.
    Q: Why is top-posting wrong? -- from lots42@xxx.com
    http://www.fscked.co.uk/writing/top-posting-cuss.html

  4. Re: How long can a bash command line be?

    voipfc wrote:
    > I want to chain a like of commands usin the &&. What is the maximum
    > length allowed - can it be user defined through some option?


    OR

    Put each command on a single line in a file and

    chmod +x filename

    The longer the line the more chance of misspelling things.

  5. Re: How long can a bash command line be?


    Matt Giwer wrote:
    > voipfc wrote:
    > > I want to chain a like of commands usin the &&. What is the maximum
    > > length allowed - can it be user defined through some option?

    >
    > OR
    >
    > Put each command on a single line in a file and
    >
    > chmod +x filename
    >
    > The longer the line the more chance of misspelling things.


    >From what I understand about the && concatenation the command following

    a && is not executed if the previous one fails, which is what I want.


  6. Re: How long can a bash command line be?

    "voipfc" writes:


    >Matt Giwer wrote:
    >> voipfc wrote:
    >> > I want to chain a like of commands usin the &&. What is the maximum
    >> > length allowed - can it be user defined through some option?

    >>
    >> OR
    >>
    >> Put each command on a single line in a file and
    >>
    >> chmod +x filename
    >>
    >> The longer the line the more chance of misspelling things.


    >>From what I understand about the && concatenation the command following

    >a && is not executed if the previous one fails, which is what I want.


    if does the same thing

    if command ; then
    othercommand
    fi
    will execute othercommand only if command works.
    Thus you can make a long command line.

    Maybe you should tell us what you want to do, ratehr than asking us if the
    solution you thought of works.


  7. Re: How long can a bash command line be?

    voipfc wrote:
    > Matt Giwer wrote:
    >> voipfc wrote:
    >>> I want to chain a like of commands usin the &&. What is the maximum
    >>> length allowed - can it be user defined through some option?

    >> OR
    >>
    >> Put each command on a single line in a file and
    >>
    >> chmod +x filename
    >>
    >> The longer the line the more chance of misspelling things.


    >>From what I understand about the && concatenation the command following

    > a && is not executed if the previous one fails, which is what I want.


    If I knew what you were trying to do I could probably figure a way
    around that. Generally the first action is creating something for the
    second action to work on. So if not created you get an error message.

  8. Re: How long can a bash command line be?

    Unruh wrote:
    > "voipfc" writes:
    >
    >
    >> Matt Giwer wrote:
    >>> voipfc wrote:
    >>>> I want to chain a like of commands usin the &&. What is the maximum
    >>>> length allowed - can it be user defined through some option?
    >>> OR
    >>>
    >>> Put each command on a single line in a file and
    >>>
    >>> chmod +x filename
    >>>
    >>> The longer the line the more chance of misspelling things.

    >
    >> >From what I understand about the && concatenation the command following

    >> a && is not executed if the previous one fails, which is what I want.

    >
    > if does the same thing
    >
    > if command ; then
    > othercommand
    > fi
    > will execute othercommand only if command works.
    > Thus you can make a long command line.
    >
    > Maybe you should tell us what you want to do, ratehr than asking us if the
    > solution you thought of works.


    Which I believe expands to more commands as

    if
    if command ; then
    othercommand
    fi
    then yetanothercommand
    fi

+ Reply to Thread