llancet has asked for the wisdom of the Perl Monks concerning the following question:
It seems to be simple, but I cannot find an way to do that. I have several tab-delimited files in one folder. I want to merge them into one file, and add a new column for file name.
For example, input files are:
file "A.tab":
file "B.tab":XXX XXX XXX XXX XXX XXX
expected output:XXX XXX XXX XXX XXX XXX
A.tab XXX XXX XXX A.tab XXX XXX XXX B.tab XXX XXX XXX B.tab XXX XXX XXX
I firstly tried to use something like this:
but it won't work, as the file name is not got in $ARGV...for file in `ls my_input_dir`; do perl -n -E 'print "$ARGV[0]\t$_"' my +_input_dir/$file; done
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to do this with shell scripting and perl one-line?
by BrowserUk (Patriarch) on Dec 29, 2011 at 11:06 UTC | |
|
Re: How to do this with shell scripting and perl one-line?
by JavaFan (Canon) on Dec 29, 2011 at 11:22 UTC | |
|
Re: How to do this with shell scripting and perl one-line?
by choroba (Cardinal) on Dec 29, 2011 at 11:07 UTC | |
|
Re: How to do this with shell scripting and perl one-line?
by hbm (Hermit) on Dec 29, 2011 at 15:05 UTC |