| | |
counting -| in Linux using grep
![]() |
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
Hello!
I would like to know how can I tell to count the number of -| (minus followed by a pipe with no space) expressions in one line using grep in a given file.
I tried grep /\-|\ |/ | filename wc -l but this does not seem to work well.
echo "sdf -| qwe-|fgh-|fubar" | sed -e 's/-|/-|\n/g' a.a |grep -- "-|" |wc -l
should do and illustrate the trick. (Hint: try '--' before an argument that begins with a '-'; many GNU program understand '--' to mean 'end of options'.)
![]() |
Other Threads in the Getting Started and Choosing a Distro Forum
- Previous Thread: Linux?
- Next Thread: Server with Fedora 9
| Thread Tools | Search this Thread |
Tag cloud for Getting Started and Choosing a Distro
age-related baremetal chrome cio cloudcomputing code commercial computers crystalballsunday desktop developers development distributions distro dsl elderly embedded forums google http://expertcore.org/ innovations jauntyjackalope joe_brockmeier kernel library linus linux microsoft multi-core netgear newbies novell openoffice.org opensuse open_source operating operatingsystems parallel performance processing redhat routers smp studios system systembuilders systemintegrators terminalservices thecloud thinclients tools ubuntu users virtualization vmware webbased wikis windows xenon





