The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 10:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 10:12 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-06-2001
frank frank is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 10
compession problem

I want to compress all the files in a given directory. My problem is that there is a file linked to another file in this directory. When I run the command

compress dir/*

I get an error because of the link

How do I compress all files except the ones that are linked??
  #2 (permalink)  
Old 11-06-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
You can write a shell script that...
1. takes a directory name as an agrument.
2. "cd"s to that directory
3. loops through all files in that directory
4. checks each file to "see" if it is not a symbolic link "if [ ! -L file ]"
5. if it is not, compress it.
6. "cd" back to starting directory
7. exit

  #3 (permalink)  
Old 11-08-2001
Rado1x Rado1x is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 35
Easier method:

find dir -type f -exec compress {} \;


:-)
  #4 (permalink)  
Old 11-08-2001
lesstjm lesstjm is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 59
I still get error messages

-rw-r----- 1 t588331 devel 155 Nov 08 10:28 grp_billing.200111
-rw-r--r-- 2 t588331 devel 29 Nov 08 10:27 frank
-rw-r--r-- 2 t588331 devel 29 Nov 08 10:27 todd

$ find /home/t588331/unixtest -type f -exec compress {} \;
/home/t588331/unixtest/todd: This file already has 1 links. It is not changed.
/home/t588331/unixtest/frank: This file already has 1 links. It is not changed.

It doesn't recognize the linked files.
  #5 (permalink)  
Old 11-09-2001
Rado1x Rado1x is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 35
Number listed in "ls -l" between permissions and user is number of "hard" links, not symbolic/soft links.


Try ls -li to obtain INODE numbers of the frank and todd files and find them second "real" names in another directories by :

find <root_of_this_filesystem> -inum .... [see man]


"compress" wants to change name to frank.Z and todd.Z and it's not possible, because "compress" doesn't know in which directory are second names located.

I'm afraid that only solution is remove the second links ...
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 04:15 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