The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
screen saver command line on solaris10-intel itik SUN Solaris 0 05-28-2008 12:01 PM
screen display help zilla30066 Shell Programming and Scripting 2 01-30-2007 07:49 PM
display full unix path as part of the command line ocelot UNIX for Dummies Questions & Answers 3 10-10-2006 03:58 PM
Display Printers via command line gseyforth Windows & DOS: Issues & Discussions 3 06-28-2006 02:02 AM
controlling screen display jrdnoland1 Shell Programming and Scripting 6 02-08-2002 05:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-01-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
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 (permalink)  
Old 07-01-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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 (permalink)  
Old 07-01-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
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 (permalink)  
Old 07-01-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
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 (permalink)  
Old 07-01-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
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 (permalink)  
Old 07-01-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
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 (permalink)  
Old 07-01-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0