0
(directory=$(python -c 'import read_params; print(read_params.get_directory())')
nsrc=$(cat $directory/master.pixels|wc -l)
tail $directory/forward_src0{1..$nsrc}_ls00/out_data_forward)

What the above does is that a simulation is running (what that is is not important) and the above command tracks it, by printing out the files in the directory:

  • ..../forward_src01_ls01/out_data_forward
  • ..../forward_src01_ls02/out_data_forward
  • ..../forward_src01_ls03/out_data_forward
  • ..../forward_src01_ls04/out_data_forward

and so on till src_08.

It runs in some linux systems without error. But in my system, it throws the below error:

[prasad@daahpc1 sparc_flows]$ (directory=$(python -c 'import read_params; print(read_params.get_directory())')
> nsrc=$(cat $directory/master.pixels|wc -l)
> tail $directory/forward_src0{1..$nsrc}_ls00/out_data_forward)
tail: cannot open /scratch/prasad/sparc_test/forward_src0{1..8}_ls00/out_data_forward' for reading: No such file or directory

To be clear, these files do exist... I can open them individually, but not in a batch.

marked as duplicate by Kusalananda bash Nov 3 '18 at 16:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Bash does not do {1..$nsrc}. The system you are using where this works may be using ksh93 or zsh, but it would not be bash. – Kusalananda Nov 3 '18 at 16:41
  • Welcome. It looks like you have an interesting question, but I can't understand it, others may misunderstand. Please proof-read and improve. (A clear question will result in better answers). – ctrl-alt-delor Nov 3 '18 at 18:45
  • I am using bash. I did echo $SHELL. And it said /bin/bash. In my local system and in the cluster – Prasad Mani Nov 4 '18 at 4:31
0

The shell in your systems seems to be different from the ones you used on the other systems (echo $SHELL)

Your local shell is not understanding/replacing the {1..8} on your tail call.

Try using the same shell on your system, also you can use the * universal wildcard instead in your script in case {1..8} can be replaced safely by *

  • 1
    I am using bash in both my local system and in the cluster – Prasad Mani Nov 3 '18 at 14:46
  • bash does not do brace expansions with variable ranges. {1..8} would not have been a problem. – Kusalananda Nov 3 '18 at 16:42

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