create PATH from find command output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers create PATH from find command output
# 1  
Old 04-01-2008
create PATH from find command output

I'm trying to autogenerate a PATH variable from the output of a find command as follows:

PATH=`find $dir -name "*.jar" | sed 's/$/:/'`

The output looks similar like this if I echo it:

PATH=/path/to/1.jar:
/path/to/2.jar:
/path/to/3.jar:

I want the path to be on one line.

I'm on Solaris 5.8
# 2  
Old 04-01-2008
|xargs
at the end of your command may help...
# 3  
Old 04-01-2008
PATH=$PATH:`find $dir -name "*.jar" | sed 's/$/:/' | xargs`

works but now the output looks like this:

PATH=/path/to/1.jar: /path/to/2.jar: /path/to/3.jar:

with spaces in between, I do the following and that works:

| sed 's/ *//g'`

so the full command is:

Code:
PATH=$PATH:`find $dir -name "*.jar" | sed 's/$/:/' | xargs | sed 's/ *//g'`

# 4  
Old 04-01-2008
Nice!
(didnt have time to go through in detail... and just poped my thoughts while trying to solve a TSM issue...)
and kind of you to share the final code.
Hope you have blue sky as we have in Geneva...
All the best
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Find command to exclude a specific path

Hi Folks, I want to run the below command and to exclude the specific path like /var/test/support/... . How to achieve using the below command find / -type f \( –perm –4000 –o –perm –2000 \) –print -Siva Please do not use FONT tags inside CODE tags. And, there is usually no reason to... (2 Replies)
Discussion started by: gsiva
2 Replies

2. Red Hat

How to find the path of a command?

Hi guys. I want to know the path of a command. I tried "which" command also . But no luck. Please tell me how to find and update the correct path of the command. Here I'm unable to find the path of ext2online command # resize2fs /dev/vg01/lvora_backup resize2fs 1.39 (29-May-2006)... (3 Replies)
Discussion started by: vamshigvk475
3 Replies

3. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies

4. Shell Programming and Scripting

find command not searching path when -newer specified

When this command is issued from a directory other than where the file is located it works fine: find /db2/D01/log_archive/ -name "S0002166.LOG" -type f /db2/D01/log_archive/db2d01/D01/NODE0000/C0000000/S0002166.LOG When I change -name to -newer, it doesn't work. Find only searches the current... (5 Replies)
Discussion started by: fletchdb2
5 Replies

5. Shell Programming and Scripting

No need path in output of LS command

hi, while i am placing the command. ls /app/callidus/rci_vst_p1/vst_fact_sms_cdr* I am getting the below ouput.. Output /app/callidus/rci_vst_p1/Inbound/vst_fact_sms_cdr_20101124.dat /app/callidus/rci_vst_p1/Inbound/vst_fact_sms_cdr_20101215.dat... (4 Replies)
Discussion started by: rsivasan
4 Replies

6. UNIX for Dummies Questions & Answers

command to find the absolute path

i understand by using the pwd command we get the present working directory. which command is used to find absolute path from home directory to root.. What is absolute path to your and root user's home directory.:confused::confused::confused: (2 Replies)
Discussion started by: shaziafathima
2 Replies

7. UNIX for Advanced & Expert Users

Help-prompt for path and take this as input in find command

HI , I am trying to wite a script that will prompt me saying " what is path that you want to find ?". once i specify the path, the script should put this path in the find command mentioned below and execute the script: find <path> -ctime +200 -type f -exec ls -l {} \; for example : ... (7 Replies)
Discussion started by: bsandeep_80
7 Replies

8. Shell Programming and Scripting

Find duplicate value comparing 2 files and create an output

I need a perl script which will create an output file after comparing two diff file in a directory path: /export/home/abc/file1 /export/home/abc/file2 File Format: <IP>TAB<DeviceName><TAB>DESCRIPTIONS file1: 10.1.2.1.3<tab>abc123def<tab>xyz.mm1.ppp.... (2 Replies)
Discussion started by: ricky007
2 Replies

9. UNIX for Dummies Questions & Answers

command to find the path of a file

What is the command to find the path of a file if we know the file name and the root directory where the file resides.. For eg. if a file abc.dat resides in /home/mydir/myfiles/. I am looking for a command which will be fired from / directory, takes abc.dat as input and display the path of... (3 Replies)
Discussion started by: abhilashnair
3 Replies

10. Shell Programming and Scripting

How would I make a find command NOT show the path of a file?

When I do find . -name "*.txt" -size +0 -exec ls {} \; I get something like ./lpi_stdout.txt ./lpi_stderr.txt What would I need to do or pipe it into to strip off those first two characters so I just get lpi_stdout.txt lpi_stderr.txt ? Thanks for the help! (1 Reply)
Discussion started by: LordJezo
1 Replies
Login or Register to Ask a Question