How can i remove the first and last character of strings like below:
"^^^613*"
"admt130"
"^^^613*"
"123456"
"adg8484"
"DQitYV09dh1C"
Means i wanna remove the quotes("").
Please help
How can i remove the first and last character of strings like below:
"^^^613*"
"admt130"
"^^^613*"
"123456"
"adg8484"
"DQitYV09dh1C"
Means i wanna remove the quotes("").
Please help
sed 's/"//g' file
Guru.
Will remove only if " is at start or end.
sed 's/^\"//;s/\"$//' inputfile
It works...only if the two extreme characters are quotes...can there be a universal sed statement that will remove the first and last character of a string like:
"nhdjfdjf"
/sjdkfjf/
dkjdbdkj;
1kfkflflf//
etc
sed 's/.\(.*\)./\1/' file
Guru.
This should fix it.
sed 's/^.\(.*\).$/\1/' inputfile
as such, the sed should work fine on a normal file..looks like your awk command is giving some extra spaces at the end..try this to remove those extra spaces:
find /test/ -name "x*.cfg"|while read i; do grep "reg.1.random" $i|awk -F"=" '{print $2}'| sed 's/ *$//'|sed 's/.\(.*\)./\1/'; done
Guru.
[root@server1 ~]# find /test/ -name "x*.cfg"|while read i; do grep "reg.1.random" $i|awk -F"=" '{print $2}'|sed 's/ $//'|sed 's/.\(.\)./\1/'; done
^^^613*
admt130"
^^^613*
123456"
adg8484"
DQitYV09dh1C
---------- Post updated at 04:51 AM ---------- Previous update was at 04:47 AM ----------
Let me give more info:
Try This
sed 's/^"\|"$//g' file
this will remove " only at beginning and end
Thanks,
Kalai
looks like there are some control characters. Redirect the output after the awk command to a file, and show us the output using cat -ve option.
I mean:
find /test/ -name "x*.cfg"|while read i; do grep "reg.1.random" $i|awk -F"=" '{print $2}' > a
cat -ve a
Guru.
find /test/ -name "x*.cfg"|while read i; do grep "reg.1.random" $i|awk -F"=" '{print $2}'| sed 's/^M//' | sed 's/ *$//'|sed 's/.\(.*\)./\1/'; done
Ctr-M should be put like this: Ctr-V + Ctrl-M
Guru.
^M should be put like: Press Ctrl and V, still holding Ctrl, press M
did you do this way?
Guru.
Try This
sed 's/^"\|"$//g' file
this will remove " only at beginning and end
Thanks,
Kalai
@guru...thanks it worked.
An alternate solution:
A single double-quote would suffice in tr.
|tr -d '"'