1

I got a task to copy files with certain extensions from clear case while I need to :

  1. find all files with certain extension and their map
  2. copy the mapping but replace the file with a dir that has it's name
  3. copy the file labels history to that dir

So I know what do to separately but can't figure how to connect things:

Code I used :

# for the latest label :
find . -name '*.extension' | cpio -pdm /path/to/save # this helped me to copy all files and their dir map

# to copy all labels for that file
\cp -r filename.extension@@/main/ /path/to/save # the @@main/ gives me the view of the labels
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
matansi
  • 11
  • 1

1 Answers1

0

and their map

The "map file" is more seen on Windows with a type manager

The map file, located in the ccase-home-dir\lib\mgrs directory, associates type manager methods with the programs that carry them out.
A map file entry has three fields: type manager, method, and program.

On Linux:

On UNIX, and Linux a type manager is a collection of programs in a subdirectory of ccase-home-dir /lib/mgrs; the subdirectory name is the name by which the type manager is specified with the –manager option in a mkeltype command.

Each program in a type manager subdirectory implements one method (data-manipulation operation).
A method can be a compiled program, a shell script, or a link to an executable.

This differs from your "dir map".

You can list labels on the current version with: cleartool descr -fmt "%l" myFile.

Using extended paths can work in a dynamic view, but it is best (to get all labels on all branches) to do a:

cleartool find . -version "!lbtype(x)" -name "yourelement" -exec "cleartool descr -fmt \"%n labels:%l\n\" \"%CLEARCASE_XPN%\""

To combine both code, do a loop on the result of the first find command.

# Make sure globstar is enabled
shopt -s globstar
for i in **/*.extension; do # Whitespace-safe and recursive
    cpio -pdm "${i}" /path/to/save
    cp -r "${i}"@@/main/ /path/to/save 
done
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • this doesnt answer my problem, i need to combine both codes i've given while instead of copying the file i need to replace the file with a dir and to there i need to copy all its labels by the cp func i gave – matansi Jul 05 '22 at 11:08
  • @matansi OK. I have edited the answer to include a way to combine both codes. – VonC Jul 05 '22 at 11:21
  • thanks ! this is really good btw if I may, is there an ebook you recommend for centos study ? – matansi Jul 06 '22 at 05:08
  • @matansi You are welcome. This is less about CentOS, and more about [shell scripts](https://www.shellscript.sh/) in this instance. That can then be applied in a [CentOS environment](https://linuxways.net/centos/how-to-create-and-run-a-shell-script-in-centos-8/). – VonC Jul 06 '22 at 05:33