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??

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

:cool:

Easier method:

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

:slight_smile:

-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.

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 ...