I have around 50 text files containing raw data and i need to print them for further analysis. The problem I am facing is that, the files themselves do not have any identifying headers and as without the file names, the data is useless to me. My question is, is there a way to print the file's content and the file name (if possible, the path also) as the header/footer of the file.
I attempted to use the lpr but it didn't workout - probably due to my complete incompetence when it comes working with printer
Otherwise, my only alternative will be to print each file and manually write the file name..............
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
Quote:
Originally Posted by Shell_Life
Code:
(echo $PWD/your_file; cat your_file) | lpr
I like that solution; I would add another echo:
Code:
(echo $PWD/your_file; echo; cat your_file) | lpr
for visual separation.
However, for many files, one would probably want to place this in a loop -- no one wants to do this 50 times manually. A script would be suitable, if one knows how to do that.
On the other hand, if one does not mind the pagination from pr, then:
Code:
pr $PWD/* | lpr
seems like a compact solution that processes all the files, the text for new files appearing at the top of a new page of paper, etc. In place of the *, other filename expressions could be used, e.g. a1[0-8] for a10, a11, ... a18, for subsets of filenames.
That's one of the useful characteristics of *nix, there is more than one approach to solving a problem ... cheers, drl
I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix.
I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice.
Files:... (3 Replies)
Hello,
I have to fish out some specific columns from a file based on the header value. I have the list of columns I need in a different file. I thought I could read in the list of headers I need,
# file with header names of required columns in required order
headers_file=$2
# read contents... (11 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (4 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (1 Reply)
this is the requirement
list.txt
table1
table2
table3
testfile.txt
name#place#data#select * from table1
name2#place2#data2#select * from table 10 innerjoin table3
name2#place2#data2#select * from table 10
output
name place table1
name2 place table3
i tried using awk (7 Replies)
Hi,
I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines).
#################################
huge_file.txt
a
a
ab
b
##################################
small_file.txt
a 1.5
b 2.5
ab ... (4 Replies)
using OS X and the Terminal, I'd like to find all locked files in a specified directory, unlock them, and print a list of those files that were unlocked
how can I do this?
I'm familiar with chflags nouchg for unlocking one file but not familiar with unix enough to do what I'd like.
Thanks! (0 Replies)
Need shell script to read two file at same time and print output in single file
Example I have two files 1) file1.txt 2) file2.txt
File1.txt contains
Aaa
Bbb
Ccc
Ddd
Eee
Fff
File2.txt contains
Zzz
Yyy
Xxx (10 Replies)
Hi
I have two files in unix. I need to compare two files and print the differed lines in other file
Eg
file1
1111
2222
3333
file2
1111
2222
3333
4444
5555
newfile
4444
5555
Thanks In advance (3 Replies)