Knowledgebase
Extracting a username from bash script output.
Posted by ZKuJoe, 02-17-2010, 04:14 AM | I currently have multiple scripts that I use to scan my server for particular files and content. I was wondering if somebody can help me take the output of that script and extract the username for me so that I can run.
Here is the code I am currently using:
Here is an example of the output:
I want to have the script still output the original results but to also extract the username so that I can take the usernames and automatically suspend the accounts using the same bash script.
|
Posted by erectvps, 02-17-2010, 04:23 AM | Try something like
/usr/bin/find /home/*/public_html/ -iname *.bz2 -type f -ls >> /var/log/alog.txt
This will do an ls of the file so using awk you can get the name + filename
e.g.
awk '{ print $6,$11 }' /var/log/alog.txt
HTH
|
Posted by ZKuJoe, 02-17-2010, 05:34 AM | Awesome! Thank you so much! This code worked perfectly!
|
Posted by ZKuJoe, 02-17-2010, 06:00 AM | Heh, found out that the following works better:
|
|
Add to Favourites
Print this Article |
Also Read