0

I have a cvs repository with different modules. The setup is always the same:

/data/cvs/<repo>/CVSROOT/passwd

I need to have a short script that loops over all repositories and performs this command:

grep "^iq" <repo>/CVSROOT/passwd | sort | uniq

The purpose is to have all usernames that start with the prefix "iq". The output will be a list with usernames, passwordhashes and the cvsmodule:

iqabcde:5!h8kdh2937slj:cvsabc

This output should be split by using ":" as terminator. I need to have 3 variables that I can access.

To be honest I don't have a lot of knowledge in shell scripting. Would be great if anyone could help, because I think this is solvable.

Thanks a lot

1 Answer 1

1

I'm bored.

#!/bin/bash
for repo in /data/cvs/*
do
  IFS=: read username hash module < <(grep "^iq" "$repo"/CVSROOT/passwd | sort | uniq)
  echo "Name: $username, Hash: $hash, Module: $module"
done
Sign up to request clarification or add additional context in comments.

5 Comments

thanks a lot for this. Most of the time I get "Name: , Hash: , Module:" as output. I suppose it is because some password hashes contain special characters? The password hash always contains 13 characters.
Weird. Which specific lines result in that?
e.g. hashes like "mE7YHNejLCviM" work, hashes like "JXfFZCZrL.6HY | JW9/ydvBFO482 | 5!b4RlH/IgYzI" don't work.
can we "hardcode" the password hash to contain exactly 13 characters?
it works when I use nawk: for repo in /data/cvs/* do grep "^iq" "$repo"/CVSROOT/passwd | sort |uniq | nawk -F ':' '{print "Name: " $1 ", Hash: " $2 ", Module: " $3 }' done

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.