cut is a Linux command that can be used to cut a line of text with a specific delimiter. I want to cut lines separated by multiple spaces like
Since the fields are separated by multiple spaces, I can’t just use cut -d’ ‘ command. What you can do is combine multiple spaces into one using tr command.
tr -s ' '
Here is the command I used to get all database name with Sleep connections
mysqladmin processlist | grep "Sleep" | tr -s ' ' | cut -d' ' -f8
Another solution is to use awk command.
mysqladmin processlist | grep "Sleep" | awk '{print $8}'
See cut
Leave a Reply