Results 1 to 1 of 1
My code is a mess right now, but what I'm trying to do and I don't know if there is a more elegant way of doing this or not since ...
- 06-17-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 10
Escape # in a bash search and sed with spaces..
My code is a mess right now, but what I'm trying to do and I don't know if there is a more elegant way of doing this or not since I'm trying to work on multiple operating systems (Mint and Ubuntu mostly, but I think it'll probably be expanded when I get the core figured out). What I'm trying to do is check for my Ubuntu users if the canonical repository is active and then install the Sun JRE for them. I don't really want to duplicate entries in case they run the script multiple times, so I believe I want to run the statement like so:
-Check if Sun JRE is installed
-If JRE installed, then do nothing
-Else move to next if
-+If -> Check if canonical package with # exists.
Then -> Remove #, apt-get JRE
-+Else -> Check if one exists without the # sign.
+> If it doesn't create one, apt-get JRE
+> if it does, apt get JRE
I can't figure out how to find and replace the text with what I'm looking for..Code:#!/bin/bash #Check if Java6 Runtime Environment is installed c=sun-java6-jre echo "checking if $c is installed" 2>&1 if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]]; then echo "echo #1 installed" 2>&1 else if grep -q "# deb ht*p://archive.canonical.com/ubuntu/ natty partner" /etc/apt/sources.list; then sed -i 's\# deb ht*p://archive.canonical.com/ubuntu/ natty partner\\deb ht*p://archive.canonical.com/ubuntu/ natty partner/g' /etc/apt/sources.list else echo "echo #2" fi fi


Reply With Quote