reference dir ../common in script
I'm trying to check for a directory and create it if it doesn't exist as follows: CommonDir="../common" if [ -d ${CommonDir} ]; then mkdir "${CommonDir}" fi It works from the command line, but my script doesn't seem to like it and I can't figure it out. Thanks for any help, Duane -- View this message in context: http://www.nabble.com/reference-dir-..-common-in-script-tp22359287p22359287.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
remove elements from an array...
-- View this message in context: http://www.nabble.com/remove-elements-from-an-array...-tp22440301p22440301.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
delete elements from an array...
I'm having a problem getting this to work. I'm currently doing this using a file instead of an array, but it is too slow. Here's what I'm trying to do: For each record in my main array (array1), I want to get a match out of array2 and append it to the array1 record. After I get the match, I want to delete that record from array2. For example, array2 looks something like this: Ohio Columbus Ohio Cleveland Texas Dallas Texas Austin I want to find the first occurrence of 'Ohio' and append Ohio and Columbus to the array1 record. Then I want to remove the 'Ohio Columbus' record from the array so I don't pick it up the next time I search on Ohio. Any help would be greatly appreciated... Duane -- View this message in context: http://www.nabble.com/delete-elements-from-an-array...-tp22440833p22440833.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
loop through records
All, I'm trying to figure out how to loop through an array of records (if possible) and reference fields in that record, but I've only been able to reference the entire array (array[0]) or when assigned with parens, there is no concept of a row... #!/bin/bash array1="187431346 0323 mirrored 11866 187431346 0324 mirrored 11866 187431346 0325 mirrored 11866 187431346 0326 mirrored 11866" element_count1=${#array1[*]} echo $element_count1 number_of_elements=${#arra...@]} echo '- ARRAY-1' for REC in "${array1[*]}" do echo "Field 1: ${REC[0]} Field 2: ${REC[1]}" done I would like to see something like this: Field 1: 187431346 Field 2: 0323 Field 1: 187431346 Field 2: 0324 Field 1: 187431346 Field 2: 0325 Field 1: 187431346 Field 2: 0326 Thanks -- View this message in context: http://www.nabble.com/loop-through-records-tp22463462p22463462.html Sent from the Gnu - Bash mailing list archive at Nabble.com.