Reputation: 4135
I have three files like this:
haeder
line
I write this:
sed '1,1d' */*filename*.txt | xarg cat > crap4.txt
and expect this:
line
line
line
but I get "cat: line: No such file or directory"...
Upvotes: 1
Views: 839
Reputation: 4135
This is what worked perfectly:
array=(*somestring*.txt)
for i in {0..2}; do
sed '1d' ${array[$i]} >> crap4.txt;
done
Bash to the rescue.
Thanx for the help.
Upvotes: 0
Reputation: 58483
This might work for you (GNU sed):
sed -s '1d' */*filename*.txt > crap4.txt
The -s
switch treats each file separately rather than the default which is as one continuous stream.
Upvotes: 3
Reputation: 161
This is a useless use of cat (as defined by Randal Schwartz). Using plain redirection works. If you really wanted to use cat, you'd want to remove 'xargs' and use '-' as an argument to cat. Here's an example to print all of the names from /etc/hosts
myhost> awk '{print $NF}' /etc/hosts | cat -
localhost
myhost
hosts
ip6-loopback
ip6-localnet
ip6-mcastprefix
ip6-allnodes
ip6-allrouters
ip6-allhosts
But using '>' instead and getting rid of the 'cat' is probably your best choice here.
Upvotes: 1
Reputation: 112386
That's because sed is sending the contents of those edited files out. The first argument cat gets is the first line of the edited file.
You're making it too complicated, you want
sed '1,1d' */*filename*.txt > crap4.txt
Upvotes: 2