Hi all
I got test.test.test and need
test.test\.test *
I need the backslash before the last dot in the line
I tried
echo test.test.test | sed 's/\./\\./g'
but it gives me
test\.test\.test
Thanks
Hi all
I got test.test.test and need
test.test\.test *
I need the backslash before the last dot in the line
I tried
echo test.test.test | sed 's/\./\\./g'
but it gives me
test\.test\.test
Thanks
Hello stinkefisch,
Following may help you in same.
echo "test.test.test" | sed 's/\(.*\.\)\(.*\)/\1\\\2 */g'
Output will be as follows.
test.test.\test *
In awk
following may help you in same.
echo "test.test.test" | awk -F"." '{$NF="\\"$NF " *"} 1' OFS="."
EDIT: Adding one more solution for same now too.
cat script.ksh
A="test.test.test"
B=${A%.*}
C=${A##*.}
echo $B".\\"$C" *"
So when we run above then following output will come.
./script.ksh
test.test.\test *
Thanks,
R. Singh
I can't figure it out ?
---------- Post updated at 05:17 AM ---------- Previous update was at 05:14 AM ----------
I need test.test\.test * as output
Hello stinkefisch,
Apologies for same(logic was correct and still same now) but I have put .
rather than \
, so changed it in above post now.
Thanks,
R. Singh
Many thanks works now
Small adaption to your non-working solution:
echo test.test.test | sed 's/\.[^.]*$/\\& */'
test.test\.test *
With RavinderSingh13's variable A, try:
echo "${A%.*}\\.${A##*.} *"
test.test\.test *
Consider also:
echo test.test.test|sed 's/\./\\&/2
s/$/ */'
producing the output:
test.test\.test *
The 2 (or any number n) flag (specifying the nth match of the BRE in the search pattern) in the substitute command being one of the few extensions that are available in sed
above and beyond the standard ed
and ex
editing commands capabilities.
Hi, for fun, an awk solution:
$ echo 'test.test.test' | awk -F\. '{$(NF-1)=$(NF-1)"\\";$NF=$NF" *"}OFS=FS'
test.test\.test *
Regards.