LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2007, 10:10 AM   #1
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Rep: Reputation: 15
find statement


Sorry to bug you. I am unable to understand the find statement in both the if else constructs. Could someone help me understand it.

Code:
 if
      [[ -z "$_Files" ]]
   then
      find . ! -path ./install -only|cpio -ocv >$_cpioFile 2>/dev/null
   else
      ls $_Files|cpio -ocv >$_cpioFile 2>/dev/null
   fi

Code:
   if
      [[ -z "$_Files" ]]
   then
      find $_Path -type f|xargs what >>$(DirectoryPath)
   else
      ls $_Files|xargs what >>$(DirectoryPath)
   fi
 
Old 12-10-2007, 02:03 PM   #2
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
First 'find': find all nodes which don't have (!) 'install' in their name, apparently intention is to skip everything in directory "./install". I don't know what "-only" means - there is no manual entry for it.

Second 'find' is easy: list all files (not directories) in whatever value of "$_Path".

I am not sure what are these scripts are intended for, and if they work at all. Do they?
 
Old 12-11-2007, 09:41 AM   #3
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Original Poster
Rep: Reputation: 15
These statements are extracted from a script. And yes they do work. Thanks for the feedback it sure was of help.

The script that was run (or contains the above statements) is under ./install directory and didnt wanted to have that included.

What is with the
Code:
xargs what
in the second find statement
 
Old 12-11-2007, 10:30 AM   #4
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
My distribution doesn't have 'what' command, but it has 'man' pages for it. It looks for a string "@(#)" in the file and prints what follows until newline. 'xargs' in 'xagrs what' provides input to 'what' command from the pipe, e.g. each line from 'ls $_Files' is given to 'what' as a input.
 
Old 12-11-2007, 11:44 AM   #5
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
The what command is/was available under Solaris and typically in source code I would insert
Quote:
# @(#)programname version information
somewhere in the header, then on a production platform program directory I could program a loop to ask of each program in turn
Quote:
what $programname
and get a list of programs and their current installed compiled versions. Of course if my interest was for a specific program then no loop needed.

As you can imagine with a multiplicity of databases up and down the country, 40+ boxes then it was handy from time to time.

Last edited by PAix; 12-11-2007 at 11:46 AM.
 
  


Reply

Tags
bash


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 08:05 PM
net use statement mnauta Linux - Networking 1 08-19-2005 01:21 PM
the FOR statement (C) sk84blood813 Programming 3 12-09-2004 08:25 AM
For Statement bendeco13 Linux - General 6 10-31-2004 05:31 PM
If Statement junjem0702 Programming 4 08-23-2004 09:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration