2

I have to run the following command:

sudo trac-admin /var/www/trac/kpi wiki remove * 

* Doesn't work, so I need change it with actual wiki names.

I have wiki names saved in a file, every name on new line.

I would like to feed contents of file as variable per single line to the original command trac-admin. How do I do this?

command that helped me delete all wikis in trac was:

for x in `cat trac.kpi.wiki2`; do sudo trac-admin /var/www/trac/kpi wiki remove $x; done

Thanks!

4

3 回答 3

2

我不确定我是否正确理解了您的问题,但也许可以尝试:

cat /var/www/trac/kpi | xargs sudo trac-admin wiki remove
于 2013-01-15T21:07:34.753 回答
0

您可以使用反引号`:

tmp]$ cat a.txt
foo
bar
baz
tmp]$ for x in `cat a.txt`; do echo $x; done
foo
bar
baz
tmp]$
于 2013-01-15T21:06:57.293 回答
0

用这个:

while IFS= read -r line; do
  sudo trac-admin /var/www/trac/kpi wiki remove $IFS;
done < /file/with/wiki/names
于 2013-01-15T21:06:38.377 回答