Tuesday, March 24, 2009
How to display content of files along with file names?
Sometimes it is useful to display content of files along with file names. egrep or pr can do the trick
$ cat 1.txt
0
1
$ cat 2.txt
2
3
#==cat can't display file name
$ cat *.txt
0
1
2
3
#==display all with wildcard filter *
$ egrep \* *.txt
1.txt:0
1.txt:1
2.txt:2
2.txt:3
#==The header of pr displays filename, sed is used to chop blank lines
$ pr *.txt sed '/^$/d'
2009-03-25 03:17 1.txt Page 1
0
1
2009-03-25 03:17 2.txt Page 1
2
3
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.