KSH CAT Two files into one


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH CAT Two files into one
# 1  
Old 11-27-2006
KSH CAT Two files into one

Quick question,

File A has one line (10 charachters), File B has one line (10 charachters).

how do a concat these two files together to produce a file (File C) that has the contents of Files A + B together onto one line of 20 Charachters

if I use:
cat FileA FileB > FileC

I get the following in FileC:
AAAAAAAAAA
BBBBBBBBBBB

When I need it on one line, i.e.
AAAAAAAAAABBBBBBBBBBB

Thanks.
# 2  
Old 11-27-2006
something like this?

Code:
cat fileA fileB | tr -d "\n" >fileC

# 3  
Old 11-27-2006
using sed

Code:
cat fileA fileB | sed 'N; s/\n//' >fileC

# 4  
Old 11-27-2006
using awk

Code:
awk -v ORS='' '{print}' fileA fileB >fileC

# 5  
Old 11-28-2006
Code:
paste a b | sed 's/\t//g'

# 6  
Old 11-28-2006
Quote:
Originally Posted by ranj@chn
Code:
awk -v ORS='' '{print}' fileA fileB >fileC

Strange ! Smilie Smilie

This ORS - Output Record seperator is not working for me
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cat N files in a folder

I am new to Linux and I am trying to cat only N files in a folder. N is dynamically given number at runtime. If I give N as 2 then cat only 2 files in the folder and If I give N as 5 then cat only 5 files in the folder. Is there any way to do that? (6 Replies)
Discussion started by: KMusunuru
6 Replies

2. Shell Programming and Scripting

CAT 3 files with the same name in 3 different folders

I am trying to cat 3 files. They all have the same name MFExtract.txt. But, they are in 3 seperate file names. Any idea how I could cat the 3 together. It's throwing me off figuring out a way because the names are the same. I was thinking just doing a 3 cat commands with the full path names and... (2 Replies)
Discussion started by: risarose87
2 Replies

3. UNIX for Dummies Questions & Answers

Using cat on specific files only

I am concatenating txt-files using cat: cat *.txt > file.dat However, the same directory has the installation instructions included, which is also a txt file: install.txt I currently have the install.txt file renamed to install._txt, but I prefer a solution using regular expressions. Is there... (5 Replies)
Discussion started by: figaro
5 Replies

4. Shell Programming and Scripting

cat certain files in directories to files named after the dir?

Hi all, I have a directory with many subdirectories each named like so: KOG0001, KOG0002, ...KOG9999. Each of these subdirectories contain a variable number two kinds of files (nuc and prot) named like so: Capitella_sp_nuc_hits.fasta (nuc) and Capitella_sp_prot_hits.fasta (prot). The... (2 Replies)
Discussion started by: kmkocot
2 Replies

5. HP-UX

cpio.cat.z files????

what are cpio.cat.z files??? Can I delete them??? (3 Replies)
Discussion started by: ldaliosmane
3 Replies

6. Shell Programming and Scripting

syntax for CAT in ksh

Just want to ask if the below code is correct; if ; then echo "No log found from " $data exit 0 else cat out.txt fi this is to test if the content of out.txt is 0 then message appear that there is no log. Is this correct? (3 Replies)
Discussion started by: harry0013
3 Replies

7. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

8. Shell Programming and Scripting

cat files in different directories

i have data files in different directories like /jadat /cadat etcc... i have list of this directories in a file files. content of files: ja ca directories: /jadat /cadat file in each of these directories natt_trans_like.dat i need to loop though each directory for a... (1 Reply)
Discussion started by: dsravan
1 Replies

9. UNIX for Dummies Questions & Answers

cat files

Hi, I was a typical Windows guy. Like to do things just by clicking my mouse:cool:. I got a new job now...where they are big on unix. I am trying to wet my fingures now with unix. Haven't taken the dive yet. I am trying to find a solution for this problem. Please help me with some... (4 Replies)
Discussion started by: sandeep78
4 Replies

10. Shell Programming and Scripting

cat /proc/ files

Hi, I need to write a shell script that should lists only the files that starts with alphabet from the /proc dir and then I have to cat those files and redirect to a file. But my below script is not working. It is reading the first file properly but not the subsequent files. Please throw a... (2 Replies)
Discussion started by: royalibrahim
2 Replies
Login or Register to Ask a Question