Results 1 to 1 of 1
Hi,
I am writing a script to get a list of users and their profile paths, from Active Directory. However, I am having problems with the shell removing the backslashes ...
- 05-27-2008 #1Just Joined!
- Join Date
- Nov 2007
- Posts
- 2
Problems with sed and backslashes
Hi,
I am writing a script to get a list of users and their profile paths, from Active Directory. However, I am having problems with the shell removing the backslashes from the paths, i.e.
Username serverusernameprofilefolder
where it should be
Username \\server\username\profilefolder
So far this is what I have handling this data... test is the file containing a dump of all AD users and their profile paths, and match is a file containing just usernames that I wish to extract from the test file.
cat test | while read a b
do
username=`echo "$a"`
if grep -i $username match > /dev/null
then
echo $a ' ' $b | sed -e 's/^\\/\\\\/g'
fi
done
The line sed -e 's/^\\/\\\\/g' gives me the two \'s at the beginning so I end up with...
Username \\serverusernameprofilefolder
But I can't find a way of retaining them all. I can't put $b in single quotes as it just echo's $b a lot.
Any help/advice would be greatly appreciated!
Many thanks.


Reply With Quote