[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quote bashslash in a shell command
From: |
jduthen |
Subject: |
Re: quote bashslash in a shell command |
Date: |
Tue, 8 Jul 2014 00:49:02 -0700 (PDT) |
User-agent: |
G2/1.0 |
Le lundi 7 juillet 2014 08:27:22 UTC+2, William Xu wrote :
> What i'd like to have is that i try a shell command on bash,
> then i can simpy copy and paste in elisp.
You could also quote the backslashs from within the shell using 'qbs':
$ function qbs() { if [ $# -gt 0 ] ; then l=$1; else read -r l; fi;
echo "$l" | sed -e 's/\\/\\\\/g'; }
$ echo foo.bar | sed -e 's/\..*//'
foo
# This command works. I want to quote the backslahs to copy it in emacs.
# So I copy and paste it into 'qbs'
$ qbs
echo foo.bar | sed -e 's/\..*//' # <- This is what I copied/pasted
echo foo.bar | sed -e 's/\\..*//' # <- This is what 'qbs' produces
# or pass it as argument to qbs:
$ qbs "echo foo.bar | sed -e 's/\..*//'"
echo foo.bar | sed -e 's/\\..*//'
HTH
)jack(