The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Differentiate Soft and Hard Link balu_solaris UNIX for Dummies Questions & Answers 2 07-18-2007 11:41 PM
hard/soft link question Browser_ice UNIX for Dummies Questions & Answers 1 08-18-2006 11:13 PM
links.... soft or hard.. not sure? yls177 UNIX for Dummies Questions & Answers 5 10-25-2002 12:12 AM
links: (soft, hard? symbolic??) inode gusla UNIX for Dummies Questions & Answers 5 05-09-2002 05:58 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-13-2006
Registered User
 

Join Date: Jan 2006
Posts: 59
Exclamation using find to locate hard and soft links with tar

I am digging for certain types of files in the current directory and all its sub-directories and archiving them with the following code:

#! /usr/bin/ksh

Archive=`date +%Y_%m_%d_%T`
find . -type f \( -name \*\.ksh -o -name \*\.sql -o -name \*\.ini \) -print|xargs tar -cf configksh_$Archive.tar

rm -rf $Archive

The problem with this piece of code I have is that-- I can't locate the links (symbolic / hard / soft.. I'm not sure of the difference either) of the resultant files.

Can somebody throw light on how I can "find" all the links recursively within the current directory along with the files that are of the desired extensions as shown. (Links , obviously, needn't have these extensions).

Correct me if I'm wrong in saying:

find . \( -type f -o -type l \) \( -name \*\.ksh -o -name \*\.sql -o -name \*\.ini \) -print|xargs tar....

to do what I want.

Thanx to all who save me quickly,
Sirisha

Last edited by manthasirisha; 03-13-2006 at 07:39 AM. Reason: Addition of a small comment
Reply With Quote
Forum Sponsor
  #2  
Old 03-13-2006
Registered User
 

Join Date: Jan 2006
Posts: 59
C'mon ppl.. it's about 20 hrs and not a single reply?!

I'm really desperate to get this right as early as possible..
I understood from a lot of posts here that there is no direct way to find hard links...except with the help of inode number. For soft links the "l" predicate in the list of file permissions when issued a "ls -l".. may help..

but i just want to confirm if i'm thinking in the right direction.

Can files of the required extensions be identified along with their links(hard or soft) using find command? If so, please enlighten me how.

Thanks a ton in advance,
Sirisha

Last edited by manthasirisha; 03-14-2006 at 06:25 AM.
Reply With Quote
  #3  
Old 03-14-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
manthasirisha,

Please note that we are not obligated to reply to your posts. Everyone on this forum has a job as a sysadmin, or a programmer or are students and are helping out on the forums in their free time.

You have already used the find command with the type predicate. Use the same command:
Code:
find . -type l -exec ls -l {} \;
This find will list all files that are soft (symbolic) links. Is this what you want?
Reply With Quote
  #4  
Old 03-14-2006
Registered User
 

Join Date: Jan 2006
Posts: 59
Blowtorch,

I never did say anything like that.. nor even did I mean when was asking help for a second time. It was a very informal and casual expression I thought, could use to request our expert friends from such a hyooooooge group. It wasn't meant to obligate anyone here to respond to it all.. it's a just a plain and urgent request! Sorry, if you felt it personal.

Thanks a ton for your advice on that! But that's not all that I'm looking for. I need a short method by which I can extract the files I need and follow up both their hard and soft links.

Hope I made myself thorougly clear!

Sirisha
Reply With Quote
  #5  
Old 03-14-2006
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,256
If you are using GNU-find: use the "-follow" clause to dereference the links if this is what you want to do.

More on this could be found at "man find".

bakunin
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0