ClearTool windows vs unix behaves different - cleartool

I used ClearCase/ClearTool several years ago in an unix env.
Now I'm in a Windows env.
The following unix cleartool command will display a version tree for each unit on my_branch all at once.
For example, if I have 5 units on my_branch, 5 version trees will be displayed at the same time:
find . -version 'version (.../my_branch/LATEST)' -exec 'cleartool lsvtree -g $CLEARCASE_PN'
I'm trying to do the same in Windows, however the following command displays a single version tree. Upon closing the version tree, the next version tree will be displayed:
find . -version 'version (.../my_branch/LATEST)' -exec 'cleartool lsvtree -g %CLEARCASE_PN%'
How do I get all version trees displayed at once in Windows?

The IBM addition example page proposes (for finding version with labels for instance):
cleartool find . -type f -exec "cleartool lsvtree -a %CLEARCASE_PN%" | findstr "("
The only difference seems to be the double quotes, but it does filter through each and every versions found.
Sale for protecting elements:
cleartool find . -all -name *.bat -print -exec "cleartool protect -chmod u+x -file ""%CLEARCASE_PN%"""
However, that triggers the command for each result, which might not be what you want.
If that still doesn't work, the other approach is to use the DOS for command:
for /f %a in ('cleartool find . -version 'version (.../my_branch/LATEST)'') do cleartool lsvtree -g %a
Again, I suspect the commands would be repeated sequencially.
The only way to achieve that on Windows would be to:
put the find result in a text, making sure those versions are displayed in one line,
then using the content of that file as parameter for your Windows cleartool lsvtree -g
(since an lsvtree command can accept several pname), and see if then several graphical version tree are displayed at once.

Related

Ansible shell calling find to exclude file with today date

My team is facing issues with Ansible shell command.
I've a directory with log files to zip and the previous processed files (which are zipped), all files are timestamped as YYYY.mm.dd like :
somefile.2021.05.19.log
somefile.2021.05.20.log
somefile.2021.06.18.log.gz
I need to zip the ones which does not contain the current date (if today is 2021.05.20, I won't zip this file). It means in the exemple above, only the somefile.2021.05.19.log must be zipped.
I'm using the shell command :
find /var/log/somedirectory -type f ! -name "*.gz" ! -path "*`date +%Y.%m.%d`*" -exec gzip -9 {} \;
which is working fine in Linux shell and doing what I need to do : does not take *.gz files, and not the one with current date.
We're migrating from a previous orchestrator to Ansible.
When using Ansible shell with this command, it doesn't filter on the date like if the -path was not well translated from Ansible to the shell.
We tried to espace " or backtick or * but nothing seems to work. It always take the 2021.05.19 file AND unfortunately the 2021.05.20 file.
Is there some way to use this command (or a better one) in Ansible ?
Thanks.

How can find the empty files that I downloaded using the curl command?

I executed curl command to retrieve, from the following webpage "http://files.rcsb.org/view/IDENTIFIER.pdb"
the PDB files that have an identifier starting with 1W followed by any digit and ending with any
upper case letter and save each into a separate file.
But some of these files don't exist. My question is how to delete them.
I first run this command to download the files:
curl http://files.rcsb.org/view/1W[0-9][A-Z].pdb -o file_#1#2.txt
I got 260 files
enter image description here
What command should I run to remove empty files? Thank you!
As far as I know, the find command has a -delete parameter you can use. It also has has a -size parameter for filtering on size. The combination of both leads to this:
find ./ -type f -size 0 -delete
The URL, I refer to, gives some more background information and examples concerning the command.
Good luck

Windows/Mac Githook For python

so I want to make a GitHook which removes .pyc files. So a simple shell script one line command would be find . -name "*.pyc" -delete and that's it. The problem is that some of my team members use Unix based Operating Systems where find . -name "*.pyc" -delete works fine, however some use Windows too where it doesent really work, so what can I do?

Find git repository on macOS

I would like to find the location of a Git repository I made on my mac. Is there a way to find, for exemple, albatrocity/git-version-control.markdown on macOS using the Terminal? I installed everything with default parameters. I guess it must be in the User directory but I don't find anything related to GitHub there.
When I find it, I would like to completely remove it to maker a "proper" install.
EDIT: sudo find / -name "parsing.py" -print
I used a file that I know the folder contained when Terminal showed me nothing with sudo find / -wholename "*albatrocity/git-version-control.markdown"
You can use find's -wholename option to find a file based on its name and folder:
find <directory> -wholename "*albatrocity/git-version-control.markdown"
Example, if you want to search in the /Users/ directory:
find /Users/ -wholename "*albatrocity/git-version-control.markdown"
If you have locate on mac, and a regularly running updatedb, locate might be much faster:
locate albatrocity | grep git-version-control.markdown
It uses a hashtable to fast access filenames, but can be out of date, if the database isn't updated regularly or the file is too young (typically less than one day old).
If this is without success, then I would go for a full search with find, but maybe restrict it to a possible, narrowed path.

Is it not possible to use the CLI, bash in this case, to find a set, take a set, move it, and not have to write a library to do so

I thought this would be more of a one liner to be honest.
Pretty simple in notion:
using find on Mac OS X, locate files that meet a criteria, in my case:
all file and directories in a directory:
find ~/Downloads +time1000s
That finds what I need, then I run a conditional, if a dir exists, delete it, if not, create it:
mkdir -p ~/.Trash/safe-to-delte-these-old-files
This means I need to add print0 to my find as files will have spaces, and I want to move, not copy but either way, there is a source, and a destination, and I am getting stuck:
https://gist.github.com/5c0tt/5a2c1fd39ae99d6fca05
Line 27 and 26 seem to cause me issues, I am stuck.
Suggestions on everyone from line 1 to the end. I am trying to hard to do this with POSIX in mind, but i can't even get variables to work then.
It seems BSD does not work the exact same way as other shells and what arguments they accept, which is why I am trying to be more POSIX, as I was told it should run anywhere then.
Thank you.
Took a glance at your git link, a couple of remarks if I may (still a noob tbh so may be irrelevant) :
dir_to_clean="/Users/my_username/Downloads" should probably be dir_to_clean="/Users/$current_user/Downloads" unless you actually have a literal /Users/my_username/Downloads folder.
Instead of cd'ing into your users directory and since you have hardcoded the path to that directory, you could use pushd & popd instead in order to build a stack of directories.
To answer your question, to capture files with spaces in the name for removal you could use something like :
find $dir_to_clean -not -name . +time1000s -exec mv -- {} ~/.Trash/
Could be something like this :
# Initialise variables, user, source to clean, destination
user=$(whoami);
src="/Users/$user/Downloads";
dest="~/.Trash/safe_to_delete";
# Move to directory to clean, not necessary, but if you really want to
pushd $src;
# Check if the destination exists, if not, create it
if [ ! -d $dest ]; then
mkdir -p $dest;
else
echo "destination already exists";
fi
# Find all the file to move then move them
find . -not -name . +time1000s -exec mv -- {} "$dest/" \;
# Return to previous working directory
popd;
pushd the $src directory onto the stack. find all the files in the now current directory ., -not -name . in order to avoid trying to trash the . & .. folders, -- tells find to stop parsing command line options (in cas your file/folder is named i.e. -myfile.txt), exec mv all of the arguments to $dest. popd the still current directory off of the stack. man find (/exec) for more details.
Note : It is also interesting to know that the difference of execution time between the -exec option versus results being piped into xargs can and will often be quite dramatic. Also, if your are actually sure that those files are safe_to_delete, then delete them instead of moving them (-exec rm -- {} $dest/). With all that said, you were correct, one liner.
Further reading :
http://www.softpanorama.org/Tools/Find/using_exec_option_and_xargs_in_find.shtml

Resources