Sponsored Content
Top Forums Shell Programming and Scripting joining multiple files into one while putting the filename in the file Post 302369218 by bakunin on Friday 6th of November 2009 11:43:59 PM
Old 11-07-2009
Replace "<tab>" with a literal tab character in the following - or adjust the output to your needs altogether. The idea should be clear enough.

Code:
#!/bin/ksh

set -A afFile "file1" "file2" "file3"
typeset -i iFileCnt=0

while [ $iFileCnt -lt ${#afFile[*]} ] ; do
     sed 's/^/'"${afFile[$iFileCnt]}"'<tab>/' "${afFile[$iFileCnt]}"
     (( afFile += 1 ))
done

exit 0

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Joining files based on multiple keys

I need a script (perl or awk..anything is fine) to join 3 files based on three key columns. The no of non-key columns can vary in each file. The columns are delimited by semicolon. For example, File1 Dim1;Dim2;Dim3;Fact1;Fact2;Fact3;Fact4;Fact5 ---- data delimited by semicolon --- ... (1 Reply)
Discussion started by: Sebben
1 Replies

2. Shell Programming and Scripting

How to redirect the output to multiple files without putting on console

How to redirect the output to multiple files without putting on console I tried tee but it writes to STDOUT , which I do not want. Test.sh ------------------ #!/bin/ksh echo "Hello " tee -a file1 file2 ---------------------------- $>./Test.sh $> Expected output: -------------------... (2 Replies)
Discussion started by: prashant43
2 Replies

3. UNIX for Dummies Questions & Answers

JOINING MULTIPLE LINES IN A TEXT FILE USING GAWK

sir... am having a data file of customer master., containing some important fields as a set one line after another., what i want is to have one set of these fields(rows) one after another in line.........then the second set... and so on... till the last set completed. I WANT THE DATA... (0 Replies)
Discussion started by: KANNI786
0 Replies

4. UNIX for Dummies Questions & Answers

Joining string on multiple files

Hi guys, I am a forum (and a bit of a unix) newbie, and I currently have a tricky problem lying ahead of me. I have multiple files, and I am looking to join the files on the first column. Example: File 1 andy b 100 amy c 200 amy d 300 File 2 andy c 200 amy c 100 clyde o 50 ... (3 Replies)
Discussion started by: jdr0317
3 Replies

5. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

6. Shell Programming and Scripting

Other alternative for joining together columns from multiple files

Hi again, I have monthly one-column files of roughly around 10 years. Is there a more efficient way to concatenate these files column-wise other than using paste command? For instance: file1.txt 12 13 15 12 file2.txt 14 15 18 19 file3.txt 20 21 (8 Replies)
Discussion started by: ida1215
8 Replies

7. Shell Programming and Scripting

Adding filename and line number from multiple files to final file

Hi all, I have 20 files (file001.txt upto file020.txt) and I want to read them from 3rd line upto end of file (line 1002). But in the final file they should appear to start from line 1. I need following kind of output in a single file: Filename Line number 2ndcolumn 4thcolumn I... (14 Replies)
Discussion started by: bioinfo
14 Replies

8. UNIX for Dummies Questions & Answers

Joining different columns from multiple files

Hello again, I am trying to join 3rd column of 3 files into the end on one file and save it separately... my data looks like this file 1 Bob, Green, 80 Mark, Brown, 70 Tina, Smith, 60 file 2 Bob, Green, 70 Mark, Brown, 60 Tina, Smith, 50 file 3 Bob, Green, 50 Mark, Brown,60 Tina,... (6 Replies)
Discussion started by: A-V
6 Replies

9. UNIX for Dummies Questions & Answers

Putting $$ before filename

Hello , I am searching a directory for a file and have to assign the filename to a variable . The variable must have form $$filename So my code is echo "'$$filename='`ls -lrt *PreMatch*.csv| head -1 | nawk '{print $9}'`" however $$ is converting to a number . How could I make it $$... (3 Replies)
Discussion started by: Pratik4891
3 Replies

10. Shell Programming and Scripting

CSV joining and checking multiple files

Hello, For our work we use several scripts to gather/combine data for use in our webshop. Untill now we did not had any problems but since a couple days we noticed some mismatches between imports. It happened that several barcodes where matched even though it was a complete other product. Of... (19 Replies)
Discussion started by: SDohmen
19 Replies
halibut(1)							   Simon Tatham 							halibut(1)

NAME
halibut - multi-format documentation formatting tool SYNOPSIS
halibut [options] file1.but [file2.but ...] DESCRIPTION
halibut reads the given set of input files, assembles them into a document, and outputs that document in one or more formats. The available command-line options can configure what formats Halibut should output in, and can also configure other things about the way Halibut works. OPTIONS
The command-line options supported by halibut are: --text[=filename] Makes Halibut generate an output file in plain text format. If the optional filename parameter is supplied, the output text file will be given that name. Otherwise, the name of the output text file will be as specified in the input files, or output.txt if none is specified at all. --html[=filename] Makes Halibut generate one or more output files in HTML format. If the optional filename parameter is supplied, there will be pre- cisely one HTML output file with that name, containing the whole document. Otherwise, there may be one or more than one HTML file produced as output; this, and the file names, will be as specified in the input files, or given a set of default names starting with Contents.html if none is specified at all. --winhelp[=filename] Makes Halibut generate an output file in Windows Help format. If the optional filename parameter is supplied, the output help file will be given that name. Otherwise, the name of the output help file will be as specified in the input files, or output.hlp if none is specified at all. The output help file must have a name ending in .hlp; if it does not, .hlp will be added. A secondary contents file will be created alongside the main help file, with the same name except that it will end in .cnt (for example output.cnt, if the main file is out- put.hlp). --man[=filename] Makes Halibut generate an output file in Unix man page format. If the optional filename parameter is supplied, the output man page will be given that name. Otherwise, the name of the output man page will be as specified in the input files, or output.1 if none is specified at all. --info[=filename] Makes Halibut generate an info file. If the optional filename parameter is supplied, the output info file will be given that name. Otherwise, the name of the output info file will be as specified in the input files, or output.info if none is specified at all. By default, unless configured otherwise using the cfg{info-max-file-size}{0} directive, the info output will be split into multiple files. The main file will have the name you specify; the subsidiary files will have suffixes -1, -2 etc. --pdf[=filename] Makes Halibut generate an output file in PDF format. If the optional filename parameter is supplied, the PDF output file will be given that name. Otherwise, the name of the output PDF file will be as specified in the input files, or output.pdf if none is speci- fied at all. --ps[=filename] Makes Halibut generate an output file in PostScript format. If the optional filename parameter is supplied, the PostScript output file will be given that name. Otherwise, the name of the output PostScript file will be as specified in the input files, or out- put.ps if none is specified at all. -Cword:word[:word...] Adds a configuration directive to the input processed by Halibut. Using this directive is exactly equivalent to appending an extra input file to the command line which contains the directive cfg{word}{word}{word...}. --input-charset=charset Changes the assumed character set for input files from the default of ASCII. --list-charsets Makes Halibut list character sets known to it. --list-fonts Makes Halibut list fonts known to it, either intrinsically or by being passed as input files. --precise Makes Halibut report the column number as well as the line number when it encounters an error in an input file. --help Makes Halibut display a brief summary of its command-line options. --version Makes Halibut report its version number. --licence Makes Halibut display its licence (MIT). MORE INFORMATION
For more information on Halibut, including full details of the input file format, look in the full manual. If this is not installed locally on your system, you can also find it at the Halibut web site: http://www.chiark.greenend.org.uk/~sgtatham/halibut/ BUGS
This man page isn't terribly complete. Halibut 2004-04-08 halibut(1)
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy