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.

filbranden
  • 21,751
  • 4
  • 63
  • 86
  • 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 03 '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 03 '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 04 '18 at 04:31

1 Answers1

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 *