Find the answer to your Linux question:
Results 1 to 2 of 2
Hello I ran across this thread and was hoping someone might be able to help me out http://www.linuxforums.org/forum/lin...sh-arrays.html Code: #!/bin/bash declare -a lines exec 3</path/to/the/file || exit 1 while read ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2006
    Posts
    1

    Bash Array


    Hello I ran across this thread and was hoping someone might be able to help me out
    http://www.linuxforums.org/forum/lin...sh-arrays.html
    Code:
    #!/bin/bash
    declare -a lines
    exec 3</path/to/the/file || exit 1
    while read curline <&3; do
        if [ -z "$curline" -o "${curline:0:1}" = "#" ]; then continue; fi
        lines=("${lines[@]}" "$curline")
    done
    exec 3<&-
    
    echo "1st line: ${lines[0]}"
    echo "10th line: ${lines[9]}"
    What does the curline variable do? I don't understand the if line and the lines= line. What is the -o and :0:1.

    Thanks,
    Nick

  2. #2
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401
    Here you can find any answer about bash scripting...

    http://www.tldp.org/LDP/abs/html/
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •