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
Help-prompt for path and take this as input in find command bsandeep_80 UNIX for Advanced & Expert Users 7 01-21-2009 04:49 PM
Using output to input another command rodrimuino Shell Programming and Scripting 3 02-14-2008 12:37 PM
Using Output from one command as input to another BkontheShell718 Shell Programming and Scripting 2 12-26-2007 04:23 PM
Using find command with awk or basename sam_78_nyc Shell Programming and Scripting 4 11-05-2007 07:49 PM
find files and using them as input arguements for another command bobbygrep UNIX for Dummies Questions & Answers 1 07-18-2001 06:24 AM

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 12-13-2008
new_learner new_learner is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 15
Question problem with output of find command being input to basename command...

Hi,

I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script.

I am planning to do like this:

if [ `find /path/abc* | wc -l` == 1 ]; then
x=`find /path/abc*`
y=`basename $x`
fi

I am triying to combine x=`find... and y=`basename... into one sentence using "|".

y=`find /path/abc* | basename`

But I am getting below error:

Usage: basename String [Suffix]

Can any one suggest if there is a better way to do this or help me combine these two commands into one.

Thank you.
  #2 (permalink)  
Old 12-13-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,419
try putting xargs after find command

Code:
y=`find /path/abc* |xargs basename`

  #3 (permalink)  
Old 12-14-2008
new_learner new_learner is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 15
Thumbs up

Thank you very much vidyadhar85.

This works.

Thanks and Regards
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 12:47 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