From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on finch.gentoo.org X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=DATE_IN_PAST_12_24,DMARC_NONE, INVALID_DATE,MAILING_LIST_MULTI autolearn=no autolearn_force=no version=4.0.0 Received: from mail5.speakeasy.net ([216.254.0.205]) by cvs.gentoo.org with esmtp (Exim 3.30 #1) id 15r0pq-0003N2-00 for gentoo-dev@cvs.gentoo.org; Tue, 09 Oct 2001 11:38:30 -0600 Received: (qmail 58045 invoked from network); 9 Oct 2001 17:39:07 -0000 Received: from unknown (HELO yde.flatmonk.org) ([66.92.103.162]) (envelope-sender ) by mail5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 9 Oct 2001 17:39:07 -0000 Received: from agriffis by yde.flatmonk.org with local (Exim 3.33 #1 (Debian)) id 15r0qO-000489-00 for ; Tue, 09 Oct 2001 12:39:04 -0500 From: Aron Griffis To: gentoo-dev@cvs.gentoo.org Subject: Re: [gentoo-dev] Short Question about sed Message-ID: <20011009123904.A15799@yde.flatmonk.org> Mail-Followup-To: gentoo-dev@cvs.gentoo.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.22.1i X-Mailer: Mutt http://www.mutt.org/ X-Editor: Vim http://www.vim.org/ Sender: gentoo-dev-admin@cvs.gentoo.org Errors-To: gentoo-dev-admin@cvs.gentoo.org X-BeenThere: gentoo-dev@cvs.gentoo.org X-Mailman-Version: 2.0 Precedence: bulk Reply-To: gentoo-dev@cvs.gentoo.org List-Help: List-Post: List-Subscribe: , List-Id: Gentoo Linux development list List-Unsubscribe: , List-Archive: Date: Tue Oct 9 11:39:02 2001 X-Original-Date: Tue, 9 Oct 2001 12:39:04 -0500 X-Archives-Salt: 982f0943-80ac-471e-9c61-8537e71fad57 X-Archives-Hash: 3c19c5e0fdb4366d5b0286cbb1486f40 Sebastian Werner wrote: [Tue Oct 09 2001, 01:27:53AM EST] > i need a solution in a script to replace all backslashes (\). I know that i > how i replace slashes (/) (sed s/"\/"/"someelse"/g) but how i replace > backslashes. sed 's/\\/replacement/' Note that if you're replacing in a shell variable, you might consider using the bash replacement syntax instead of calling out to sed. Usage: VAR="${VAR#patt}" # snip shortest match from front VAR="${VAR##path}" # snip longest match from front VAR="${VAR%patt}" # snip shortest match from end VAR="${VAR%%path}" # snip longest match from end VAR="${VAR/patt/repl}" # replace first occurance VAR="${VAR//patt/repl}" # replace all occurances VAR="${VAR/#patt/repl}" # replace, rooted to beginning (^ in regex) VAR="${VAR/%patt/repl}" # replace, rooted to end ($ in regex) Examples (not necessarily practical): progname="${0##*/}" # snip entire path from program name newvar="${oldvar//\\\\/backslash}" # note that \\\\ matches one backslash! set -- "${@/#/$D/}" # prepend $D/ to all args newarray=("${@/#/$D}") # same as last example, but put in newarray Aron