Reputation: 555
I am trying to sort a bunch of files in a bash loop numerically (option -n) according to the second column (option -k 2):
for ch_perm in {0..99}; do
for ch_set in {1..15}; do
sort -nk 2 $ch_perm.results.$ch_set > sortedbyscore2/$ch_perm.results.$ch_set ;
done
done
But the sort won't work correctly. Would anybody know? Thanks in advance!
This is the output I get:
for ch_perm in {0..99}; do
> for ch_set in {1..15}; do
>
Display all 1504 possibilities? (y or n)
11.results.21 13.results.35 15.results.49 3.results.61 5.results.74 7.results.88 [...]
> -k 2 $ch_set.results.$ch_perm > sortedbyscore2/$ch_set.results.$ch_perm ;
> done
> done
-bash: -k: command not found
-bash: -k: command not found
-bash: -k: command not found (many many times)
Upvotes: 0
Views: 43
Reputation: 6847
You have used tabs to indent the script, which is then confusing bash when you paste it into the terminal, and you end up triggering bash's autocomplete with a double tab. You can see that the "sort" has been lost when that happened.
Indent with spaces, or put this script in a file and run it from there.
Upvotes: 4