how to concatenate two command in one line and get the display in one screen


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to concatenate two command in one line and get the display in one screen
# 1  
Old 07-01-2005
how to concatenate two command in one line and get the display in one screen

Hi,

I would like to know , how to concatenate two command in one line and get the display in one screen

for eg

command 1 : ls -l /data/logs
command 2 : ls -l /data/errors

output shd be

/data/logs /data/errors
xx-xx-xx-xx abc.log xx-xx-xx-xx abc.err
xx-xx-xx-xx abc1.log xx-xx-xx-xx abc1.err
xx-xx-xx-xx abc2.log xx-xx-xx-xx abc2.err

is this kind of output is possible , pls help
# 2  
Old 07-01-2005
How about this ?

Code:
#! /bin/sh

for logs in `ls /data/logs`
do
LOGS="$logs"
  for err in `ls /data/errors`
  do
  ERR="$err"
  echo "$LOGS  $ERR"
  break
  done
done

Vino
# 3  
Old 07-01-2005
vino

in the script that u had provided

all the files under the first for loop (outer for loop) would be listed

and since there is a break statement in the second for loop
for all the files from the outer for loop only the first file would be printed from the second loop.

To put in more specific terms
ls /data/logs
1.txt
2.txt

ls /data/errors
3.txt
4.txt

output would be:
1.txt 3.txt
2.txt 3.txt

the file 4.txt will not be listed

but the required output is of the form
xx-xx-xx-xx abc.log xx-xx-xx-xx abc.err
xx-xx-xx-xx abc1.log xx-xx-xx-xx abc1.err
xx-xx-xx-xx abc2.log xx-xx-xx-xx abc2.err

plz let me know if i had misinterpreted anywhere .

***********************
you can try this... (this is not an efficient way)

ls -l | /data/logs | grep -v total | awk '{print $1, $9}' > t
ls -l | /data/errors | grep -v total | awk '{print $1, $9}' > t1

paste -d"\t" t t1

would give the required output
# 4  
Old 07-01-2005
its is not working

i am getting the display like

total total
3624 total
-rw-r--r-- total
1 total
roam total
oradba total
3575834 total
Jul total
1 total
12:04 total
access.log total
-rw-r--r-- total
1 total
roam total
oradba total
7 total
Jul total
1 total
12:00 total
access_pointer.txt total
-rw-r--r-- total
1 total
roam total
oradba total
88051 total
Jul total
1 total
12:04 total
kannel.log total
# 5  
Old 07-01-2005
your output seems to have

string total

but i had used grep -v total no way u can get total

ls -l | /data/logs | grep -v total | awk '{print $1, $9}' > t
ls -l | /data/errors | grep -v total | awk '{print $1, $9}' > t1

paste -d"\t" t t1


can u please the change the command to following

ls -l /data/logs | grep -v total | awk '{print $1, $9}' > t
ls -l /data/errors | grep -v total | awk '{print $1, $9}' > t1

paste -d"\t" t t1

and let me know how do u proceed.
# 6  
Old 07-01-2005
actually that output is for the earlier script which u gave.. pls ignore

i have ran the latest script and got the output like this

-rw-r--r-- afiedt.buf drwxr-xr-x analysis
-rw-r--r-- analyzer.log drwxr-xr-x gdbm
-rw------- cancel.gdbm drwx------ lost+found
-rw-r--r-- change.log -rw-r--r-- message.log
-rw-r--r-- counters.log.bz2 -rw-r--r-- roamer.log
-rw------- dbm_messenger.dbm
-rw-r--r-- dp5.log

yes, the output is fine, but the thing is it is not aligned , is there any way i can get like

-rw-r--r-- afiedt.buf <space><sapce> drwxr-xr-x analysis
-rw-r--r-- analyzer.log<space><sapce> drwxr-xr-x gdbm
-rw------- cancel.gdbm<space><sapce>drwx------ lost+found
-rw-r--r-- change.log<space><sapce>-rw-r--r-- message.log
-rw-r--r-- counters.log.bz2<space><sapce>-rw-r--r-- roamer.log
-rw------- dbm_messenger.dbm
-rw-r--r-- dp5.log
# 7  
Old 07-01-2005
i believe the <space> that u had mentioned are <tabs> if i am right

and the output u obtained is what u required right ???

so what is the required format for ur output, send us that also.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

How to display certain line of file only using head or tail in 1 command?

First month learning about the Linux terminal and it has been a challenge yet fun so far. We're learning by using a gameshell. I'm trying to display a certain line ( only allowed 1 command ) from a file only using the head or tail. I'm pretty about this answer: head -23 history.txt | tail -1... (1 Reply)
Discussion started by: forzatekk
1 Replies

2. HP-UX

Display SAM user list at the command line

Hello, I've been doing Linux and AIX administration for years, but I'm very new to HPUX. We have an old audit process which involves someone manually using sam to generate user lists. I'd like to kill that old process with fire... But... After working a bit in the morning to try and pull... (3 Replies)
Discussion started by: Celt1977
3 Replies

3. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

4. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

5. Shell Programming and Scripting

Display Specific line number using tail command

Hi , 1)i want to display specific line number using tail command. e.g. display 10 line from end. Please help... 2)Want to display line 10 to 15 (from end)using tail command) (2 Replies)
Discussion started by: vivek1489
2 Replies

6. Shell Programming and Scripting

display warning messages on command line

I have made a script to print size of a slice if it reaches more then 80% which is working fine no problem in it. I want to add this script in crontab to print this message on command line every half hour if slice size reaches more then 80%. here is the line below i added on crontab 30 *... (2 Replies)
Discussion started by: Danish Shakil
2 Replies

7. Shell Programming and Scripting

concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line. 2 lines from log: 2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (7 Replies)
Discussion started by: vithala
7 Replies

8. UNIX for Advanced & Expert Users

Need solution concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line. 2 lines from log: 2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (1 Reply)
Discussion started by: vithala
1 Replies

9. Solaris

screen saver command line on solaris10-intel

Hi All, I'm on Solaris10-intel and I'm on the classic GUI, CDE. Can't find the control for screen saver. Is there's a command line equivalent? Thanks in advance, itik (0 Replies)
Discussion started by: itik
0 Replies

10. Windows & DOS: Issues & Discussions

Display Printers via command line

Is there an easy way to view all printers on a local machine via command line or a script? I'm looking for the equivalent of clicking on "START, CONTROL PANEL, PRINTERS AND FAXES" to view the devices. I then want to cat it to a file where I would use it later. Thanks (3 Replies)
Discussion started by: gseyforth
3 Replies
Login or Register to Ask a Question