How can I append the name of a file to end of each line in that file?

I need to do the following for hundreds of files: Append the name of the file (which may contain spaces) to the end of each line in the file.

It seems to me there should be some way to do this:

sed -e 's/$/FILENAME/' *

where FILENAME represents the name of the current file. Is there a sed variable representing the current filename? Or does anyone have a different solution using bash, awk, etc.?

Answers


I'm sure there are other ways to do it, I'd use perl:

perl -p -i -e 's/$/$ARGV/;' *

Need Your Help

Horizontal ListView with parchment library error

android listview android-listview horizontallistview

I m just trying to use parchment library to add an horizontal listView but it doesn't work for me.

Front end private messaging plugin wordpress

php wordpress wordpress-plugin user

i'm looking everywhere for a private messaging plugin for wordpress.