Question on Cut
Hi Team.
Got a question I have variable AB.16.89 i need to change it to AB1689 not sure how to change it using cut (or) awk. SYIN=AB.16.89 echo $SYSIN|cut -d '.' -f * ??? |
I would use tr or sed to simply delete the '.'s
|
If all you're trying to do is remove the periods then arguably the most appropriate tool (though as with most text manipulation tasks in bash not the only one) for the job is sed:
Code:
man sed Code:
echo $SYSIN | sed 's/\.//g' Code:
's(search and replace)/regex pattern to match/replacement/g(replace all matches, not just one)' |
Code:
echo AB.16.80 | sed 's/\.//g' |
thanks solved my proble
|
Here's the tr solution
Code:
echo AB.16.80 | tr -d '.' |
Since the string is assigned to a variable, I suggest a simple parameter substitution:
Code:
SYSIN=${SYSIN//./} |
If you arw using bash, then use bash ;)
Code:
MyVar=AB.16.80 "Bash string manipulation" |
All times are GMT -5. The time now is 07:03 AM. |