Internal: Using the grep Command with EZproxy
How to grep for a single word
We will start the grep at the home directory on our hezppyof01zxm1 terminal. Here is an output of the pwd command:
username@hezppyof01zxm1:~$ pwd
/home/username
The "$" confirms that the user is in the home directory.
username@hezppyof01zxm1:~$ cd $HEZP/searchfiles
cd stands for "change directory", "HEZP" stands for the environment variable for the hosted ezproxy environment, and "searchfiles" is the subdirectory in the HEZP environment variable.
Here is an example of grepping for "scopus" in the config.txt (*_config.txt refers to config.txt for all hosted domains)
username@hezppyof01zxm1:/preprod/hezp/trunk/searchfiles$ grep -i scopus *_config.txt
Search for multiple words using grep:
Here is an example of searching for Adam Matthew in all of the config.txt files on our hosted environment.
username@hezppyof01zxm1:/preprod/hezp/trunk/searchfiles$ grep -i "Adam Matthew" *_config.txt
Searching for patterns with special characters using grep:
Use (quotations) when searching for a pattern like for example, "auth=shib"
username@hezppyof01zxm1:/preprod/hezp/trunk/searchfiles$ grep -i 'auth=shib' *_user.txt
We can also search in multiple files for the same pattern, "auth=shib" in user.txt, as well as the ezproxy.usr. This command uses grep to search for a specific text pattern across multiple files with different extensions.
Searching for patterns in multiple files using grep:
username@hezppyof01zxm1:/preprod/hezp/trunk/searchfiles$ grep -i 'auth=shib' *_user.txt *_ezproxy.usr
username@hezppyof01zxm1:/preprod/hezp/trunk/searchfiles$ grep -i 'auth=shib' *_user.txt *_ezproxy.usr
Components of the Command:
Here is an overview of the elements of the grep command: grep -i 'auth=shib' *_user.txt and grep -i 'auth=shib' *_user.txt *_ezproxy.usr
grep: The Linux/Unix command used for searching text patterns in files
-i: An option flag that makes the search case-insensitive. This means it will match "auth=shib", "AUTH=SHIB", "Auth=Shib", etc.
'auth=shib': The text pattern being searched for is enclosed in quotes to ensure special characters (like the equals sign) are treated as literals.
This appears to be searching for the EZproxy authentication directive related to Shibboleth
*_user.txt *_ezproxy.usr: Multiple file pattern specifications.
*_user.txt: Matches all files that end with "_user.txt" in the current directory.
*_ezproxy.usr: Matches all files that end with "_ezproxy.usr" in the current directory.