Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] Odd command behaviour  (Read 1512 times)

Offline clubex

  • User
  • Posts: 265
[EN] Odd command behaviour
« on: 2015/12/22, 00:14:53 »
Does anyone know why
Code: [Select]
~/cleanup$ for i in 'cat replace.txt' ; do apt-get download $i/sid; done

produces
Code: [Select]
E: Unable to locate package cat
E: Unable to locate package replace.txt
E: Couldn't find any package by glob 'replace.txt'
E: Couldn't find any package by regex 'replace.txt'
on my en_gb machine?

Yet a copy paste from this site does what it's supposed to do.
EDIT: This happens both in bash and tty.

Offline jure

  • User
  • Posts: 635
Re: Odd command behaviour
« Reply #1 on: 2015/12/22, 00:29:20 »
is there a space between  'cat replace.txt' and ";"  ?
Code: [Select]
~/cleanup$ for i in 'cat replace.txt' ; do apt-get download $i/sid; done
Gruss Juergen

Offline horo

  • User
  • Posts: 199
Re: Odd command behaviour
« Reply #2 on: 2015/12/22, 07:40:29 »
try
Code: [Select]
for i in $(cat replace.txt) ...instead of the wrong backticks '...'
Ciao, Martin
« Last Edit: 2015/12/22, 13:41:32 by horo »
omnia vincit pecunia :(

Offline clubex

  • User
  • Posts: 265
Re: Odd command behaviour
« Reply #3 on: 2015/12/22, 09:31:24 »
Thanks guys
Jure:
Shouldn't make any difference IMO.

horo:
Thast worked OK! But I dont't seee why, unless there is a character set or language  problem on my machine. (I did read somewhere about some difference between the en_Us and en_GB language packs.)

Offline towo

  • Administrator
  • User
  • *****
  • Posts: 2.938
Re: Odd command behaviour
« Reply #4 on: 2015/12/22, 10:22:26 »
Code: [Select]
for i in 'cat foo'wrong!


Code: [Select]
for in in `cat foo`right


You see the difference?


That's why
Code: [Select]
for i in $(cat foo)
[/size][size=78%]is the better variant.[/size]
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.