Formatting required with the output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting required with the output
# 1  
Old 08-04-2014
Formatting required with the output

i have a o/p from find command that needs to be formatted

currently when i'm running

Code:
find . -name "v.info"

it is giving below o/p


Code:
/o/a/b/c/v.info
/o/a/b/c/d/v.info
/o/aa/bb/cc/v.info
/o/aa/bb/cc/dd/v.info

my requirement is if v.info is coming under sub-directories it shul be displayed only once

the o/p shul be

Code:
/o/a/b/c/v.info
/o/aa/bb/cc/v.info

# 2  
Old 08-04-2014
Quote:
Originally Posted by nikhil jain
i have a o/p from find command that needs to be formatted

currently when i'm running

Code:
find . -name "v.info"

it is giving below o/p


Code:
/o/a/b/c/v.info
/o/a/b/c/d/v.info
/o/aa/bb/cc/v.info
/o/aa/bb/cc/dd/v.info

my requirement is if v.info is coming under sub-directories it shul be displayed only once

the o/p shul be

Code:
/o/a/b/c/v.info
/o/aa/bb/cc/v.info

The output from the command:
Code:
find . -name "v.info"

can't ever be the output you showed us above. Any output from this command would have every line start with ./; not with /o.

You said you wanted v.info listed only once and then show us that you want it listed twice. How did you decide which two of the four lines reported by find should be listed as your single line of output???
# 3  
Old 08-04-2014
sorry my mistake I men't find /o

but my requirement is i want v.info to be displayed only once, if it is found in subdirectories then it can be ignored.

Code:
/o/a/b/c/v.info
/o/a/b/c/d/v.info
/o/aa/bb/cc/v.info
/o/aa/bb/cc/dd/v.info

for ex in above v.info is found under c directory as well as under d directory, So once it is found in c directory it should not display under d directory

Last edited by rbatte1; 08-04-2014 at 10:38 AM.. Reason: Added ICODE tags
# 4  
Old 08-04-2014
You might want to filter the find result like this:
Code:
find ... | while read i; do for j in ${P[@]}; do [ "$i" != "${i#$j}" ] && continue 2; done; echo $i; P[((++CNT))]=${i%/*}; done
/o/a/b/c/v.info
/o/aa/bb/cc/v.info

# 5  
Old 08-04-2014
Rudi,

It din't help

it is giving me some weird o/p

Code:
find /opt/ctier/Commander/depots/RWS/deployments -name "version.info"| while read i; do for j in ${P[@]}; do [ "$i" != "${i#$j}" ] && continue 2; done; echo $i; P[((++CNT))]=${i%/*}; done

Can you plz be more specific, thanks for ur time & help Smilie
# 6  
Old 08-04-2014
Give us the output of
Code:
find /opt/ctier/Commander/depots/RWS/deployments -name "version.info"

, and the "weird output".
# 7  
Old 08-04-2014
Rudi,

I'm sorry for that,

but my requirement is if v.info is found in sub directories it shul not be listed

Code:
/o/a/b/c/v.info
/o/a/b/c/d/v.info
/o/aa/bb/cc/v.info
/o/aa/bb/cc/dd/v.info

i want the o/p to be

Code:
/o/a/b/c/v.info
/o/aa/bb/cc/v.info

when find command is run or with any other utility in unix which list files under directories
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatting output

I have the output like below: DEV#: 9 DEVICE NAME: hdisk9 TYPE: 1750500 ALGORITHM: Load Balance SERIAL: 68173531021 ========================================================================== Path# Adapter/Path Name State Mode Select Errors 0 ... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

2. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

3. Shell Programming and Scripting

Awk help required for formatting digits.

Hi experts, I have two values in the file : For example : partcamt = 72.90 partdamt=27.9 I need to convert these values into 6 digits and ignore the "." sign so that the desired desired output is : total value= 0072000027900 Currently I am using the following code : ... (3 Replies)
Discussion started by: nua7
3 Replies

4. Shell Programming and Scripting

Output formatting .

below is a CPU utilization Log for ABC server. However for every 15 minutes it generates 3 CPU values(with interval of 2 sec). Host CPU CPUtotal CPU% time ABC 101.1 2 50.55 14 : 15 ABC 100.5 2 50.25 14 : 15 ABC 100.2 2 50.1 14 : 15 ABC 100.9 2 50.45 14 : 30 ABC 100.5 2 50.25 14 : 30 ABC... (5 Replies)
Discussion started by: pinga123
5 Replies

5. Shell Programming and Scripting

Formatting of output

Hi Experts, I have to create a report for certain audit and my output looks as follows I m trying to format my output to look like Any inputs would be highly appreciated Thanks Syed (5 Replies)
Discussion started by: maverick_here
5 Replies

6. Shell Programming and Scripting

Formatting my output

Dear All, I am new to unix scripting. I need your help to format my output on screen. echo " --------------------------------------------" echo " | My Output |" echo " --------------------------------------------" echo " | A: $A... (5 Replies)
Discussion started by: rahiljavaid
5 Replies

7. Shell Programming and Scripting

Help required with formatting in scripting

Hi Friends, I need to write a script which reads the file and prints them horizontally. For example, the file contains something like x1 x2 x3 x4 x5 my script reads this file as "for i in `cat filename`", but I need an output something like "config file = x1.ccfg,... (3 Replies)
Discussion started by: dineeshkg
3 Replies

8. UNIX Desktop Questions & Answers

Help required with formatting

I would appreciate any help (sed / awk / perl) on the following question. I have the file in the following format. Note that the records are separated by the line that starts with the word "TRACE".I want the 5th and 6th values on the line starting with "TRACE" to be repeated down the file until the... (3 Replies)
Discussion started by: digipak
3 Replies

9. Shell Programming and Scripting

formatting output

Hi need some advice.. #grep -i hostname test.csv (gives the below output) HOSTNAME,name,host_test,,,,,,,, Now I need to format the above output as below. HOSTNAME: name=host_test Any easy way of doing this using awk or sed or printf? (4 Replies)
Discussion started by: balaji_prk
4 Replies

10. Shell Programming and Scripting

Formatting the output

Hi all, Have the following code(1) producing the results(2 & 3). Would like to know if there is a way to format the two reports created in a similar fashion. IE - The first is formatted nicely as a result of the echo "$xmpbdate $xavgs" >> $xmpbrpt However when I attempt to do the same on... (7 Replies)
Discussion started by: Cameron
7 Replies
Login or Register to Ask a Question