Hello halogen2
Many thanks for the quick reply I should have been more specific with my request my apologies,
My file is actually more similar to:
Here Is Some Text 30
Hello World 10
More Text 1
I've edited the code you wrote adding in:
Code:
# Parse the file into two arrays, one of the names (e.g. XYZ) and another of the $
names=($(cat "$yourfile" | sed -r -e 's/\t.*$//g'))
numbers=($(cat "$yourfile" | sed -r -e 's/^.*\t//g'))
# Process the arrays by iterating through the indices
# Note: this assumes the two arrays are the same length
for i in $(seq 0 $((${#names[@]} - 1)));do
if [[ "${numbers[$i]}" -gt 30 ]];then
# do what you want with "${names[$i]}" here
echo "${names[$i]}" >> 2.tmp
However the code writes to file like this:
Code:
Here
is
some
text
hello
world
more text
How would I edit the command to write to file:
Code:
Here Is Some Text
Hello World
More Text
Many thanks once again for all your help
Lewis
Bookmarks