Sort 35 Discussions, By:
Please Login in order to post a comment
uniq -ci | sed 's/^[ \t]*//'
Plz make me understand. I am unable to get the logic after pipe.
uniq's output format doesn't match that required by the guidelines ("There shouldn't be leading or trailing spaces. Please note that the uniq -c command by itself will generate the output in a different format.").
sed "is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline)."
The relevant section is "s/REGEXP/REPLACEMENT/FLAGS". This uses regex (so you would need to review that, if you are not familiar - it's basically a way to match patterns in text). The "^" is the anchor for the beginning of the line. The "[ \t]" is a character class containing both a space and a tab. The "*" means to match the character class 0 or more times.
Since the REPLACEMENT section is blank (//), that means to match either a space or a tab as many times as it occurs at the beginning of the line and replace it with nothing. Essentially, this just removes the blank space at the beginning of the line, formatting it as directed.
Thanks a lot for interpreting the commands.
uniq -ci | sed 's/[[:space:]]*//'
Is also the same
uniq -ic|cut -c7-
uniq -c -i | grep -Eo '\d.*'
tr [:upper:] [:lower:] | uniq -c | cut -b7-
this is working proerly
tr 'A-Z' 'a-z' | uniq -ci | cut -c7-
first the tr command with translate and take the lower case letter, next the uniq command with ignore and count the unique value then the spaces can be elimiated by cut