Combile two files - report should be in single row


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Combile two files - report should be in single row
# 1  
Old 04-09-2011
Combile two files - report should be in single row

Dear sir

I am having a file x.lst having
abcd
andother file y.lst having
efgh

I should get report file having the result in a single row as

abcdefgh

pls help
# 2  
Old 04-09-2011
look into 'man paste'
# 3  
Old 04-09-2011
Worked on FreeBSD :
Code:
cat file1 file2 | paste -s -d \0 -

# 4  
Old 04-09-2011
not on ubuntu linux:
Code:
miro@miro-ntb:tmp$ cat fact.sh
#!/bin/bash

function fac {
    N=$1
    fact=1
    while [ $N -gt 1 ] ; do 
	fact="${fact}*${N}"
	((N--))
    done
echo $fact | bc
}

fac $1
miro@miro-ntb:tmp$ cat fact.sh fact.sh | paste -s -d \0 -
#!/bin/bash00function fac {0    N=$10    fact=10    while [ $N -gt 1 ] ; do 0	fact="${fact}*${N}"0	((N--))0    done0echo $fact | bc0}00fac $10#!/bin/bash00function fac {0    N=$10    fact=10    while [ $N -gt 1 ] ; do 0	fact="${fact}*${N}"0	((N--))0    done0echo $fact | bc0}00fac $1

This, however will do the trick:
Code:
miro@miro-ntb:tmp$ paste -d"\0" fact.sh fact.sh 
#!/bin/bash#!/bin/bash

function fac {function fac {
    N=$1    N=$1
    fact=1    fact=1
    while [ $N -gt 1 ] ; do     while [ $N -gt 1 ] ; do 
	fact="${fact}*${N}"	fact="${fact}*${N}"
	((N--))	((N--))
    done    done
echo $fact | bcecho $fact | bc
}}

fac $1fac $1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find files with 1 single row - UNIX

Hi, How could Find files with 1 single row in unix I need delete files with 1 single row (8 Replies)
Discussion started by: Marlboro
8 Replies

2. Shell Programming and Scripting

Splitting single row into multiple rows based on for every 10 digits of last field of the row

Hi ALL, We have requirement in a file, i have multiple rows. Example below: Input file rows 01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212 01,1,102319,0,1,80,20,U,1,241,00000059420000006021 I need my output file should be as mentioned below. Last field should split for... (4 Replies)
Discussion started by: kotra
4 Replies

3. Shell Programming and Scripting

Create multiple files from single file based on row separator

Hello , Can anyone please help me to solve the below - Input.txt source table abc col1 char col2 number source table bcd col1 date col2 char output should be 2 files based on the row separator "source table" abc.txt col1 char (6 Replies)
Discussion started by: Pratik4891
6 Replies

4. UNIX for Dummies Questions & Answers

Sftp transfer doing as single row

Hi All, I have a file in windows when I transfer it using sftp it is getting as single line. I tried to do both ascii and binary File: is transfered as Can you please let me know how can do the transfer as same as XML file Thanks, Arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

5. Shell Programming and Scripting

Comparing two files on row by row and send the report

Comparing two files on row by row File1 ecount~100 dcount~200 ccount~300 zxcscount~5000 and so on. File2 ecount~100 dcount~203 ccount~300 zxcscount~5000 and so on. If i use diff command (1 Reply)
Discussion started by: onesuri
1 Replies

6. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

7. Shell Programming and Scripting

help to combile two text files

i am having 2 text files 111|rama 222|krishna 333|jaya and 111|22|43 222|66|42 i want to combine these two text files,the output should be as follows 111|rama|22|43 222|krishna|66|42 333|jaya|| pls help Please use code tags when posting data and code samples! (4 Replies)
Discussion started by: suryanarayana
4 Replies

8. Shell Programming and Scripting

Convert columns to single row

Hello all I have data like 1 2 3 4 5 I wish my output would be like 1,2,3,4,5 For this i have executed 'BEGIN {FS="\n"; ORS=","} {print $0}' test and got the output as 1,2,3,4,5, I do not want to have , at the end of 5. output should be like (5 Replies)
Discussion started by: vasuarjula
5 Replies

9. UNIX for Advanced & Expert Users

Converting rows to a single row

Hi all I have a file as below : Development System User Production i want to convert the file to below format: "Development","System","User","Production" Is it possible with UNIX ? if so can you please give me some direction on it ? Thanks, Satya Use code tags please, ty. (10 Replies)
Discussion started by: satyaranjon
10 Replies

10. UNIX for Advanced & Expert Users

convert rows to single row

Hi I want to convert multiple rows ro single row ,I have tried with below one but I am not getting what I am expecting.Please any idea a.txt conn1=stg conn2=dev path=\xxx\a1.txt fre=a conn1=stg conn2=dev path=\xxx\a2.txt freq=a awk '/a/{ORS=" "}{print}END{print "\n"}'... (5 Replies)
Discussion started by: akil
5 Replies
Login or Register to Ask a Question