3

I'm trying to stack some text files as new columns. The files are named energies_Strength0.0BosonsXXX.txt where XXX is 80,90,100 or 110. When I run the following command:

paste energies_Strength0.0Bosons{110..80..10}.txt | column -s $'\t' -t > energies_Strength0.0.txt

I get the following error:

paste: energies_Strength0.0Bosons{110..80..10}.txt: No such file or directory
paste: energies_Strength0.1Bosons{110..80..10}.txt: No such file or directory
paste: energies_Strength0.05Bosons{110..80..10}.txt: No such file or directory
paste: energies_Strength0.15Bosons{110..80..10}.txt: No such file or directory

This same command works just fine if files are indexed in unit steps. This is, if XXX={80,81,82,...,109,110} and I run the command:

 paste energies_Strength0.0Bosons{110..80}.txt | column -s $'\t' -t > energies_Strength0.0.txt

EDIT:

Hello there, I have tried the following lines based on your idea:

#$ -S /bin/bash
LANG=C 

for ((i=110; i>=80; i-=10));
do
paste energies_Strength0.0Bosons$i.txt | column -s $'\t' -t > energies_Strength0.0.txt
done 

but it only pastes the ...Bosons80.txt file. I need to build an structure like the following:

paste ...80.txt ...90.txt ...100.txt ...110.txt | column -s $'\t' -t > energies_Strength0.0.txt
3
  • Run echo {110..80..10}.txt and see what you get.
    – anubhava
    May 19, 2014 at 14:48
  • I simply get {110..80..10}.txt which I guess it means expanding is just not wot working. Btw, echo {110..80}.txt does work. I'm on OSX 10.6.4 May 19, 2014 at 14:57
  • 1
    was nobody going to mention the possibility of {11..8}0
    – user2404501
    May 20, 2014 at 13:30

3 Answers 3

6

{110..80..10} syntax is only supported on BASH 4+ VERSIONS.

On OSX your BASH version is 3.2.xx

You can use this alternative arithmetic looping:

for ((i=110; i>=80; i-=10)); do echo $i.txt; done
0
5

bash >=4 {100..80..10}

bash <4 you could seq 80 10 100

example:

kent$ seq -f '%g.txt' 80 10 110
80.txt
90.txt
100.txt
110.txt
0

{A..B} is well-defined Bash syntax called brace expansion, when A and B are integers. {A..B..C} does not follow this pattern, so it's interpreted as a literal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.