Search Objective-C source file for tag listing and sort

grep '.tag =' <file> | awk '{print $3}' | awk 'sub(/[;]/, x)' | sort -n
I use this one-liner to search my sourcecode to find out where tags are named and since there's no easy way in XCode to see what values have already been used.
Sample Output
1
2
3
4
5
6
7
8

0
2013-05-21 15:58:16

These Might Interest You

  • Dave Korn gave me this one. It works because ksh allows variable names ( w/o the $name syntax ) used by sh and bash. I wrote it to permit "single source" shell libraries; the current objective: every shell library may be sourced by either shell. see http://github.com/applemcg/backash Show Sample Output


    2
    isKsh () { one=1; [ one -eq 1 ] 2> /dev/null; }
    applemcg · 2014-11-18 20:45:12 0
  • Replace all instances of "A" with "B" in file "source" saved as file "destination". !! IF A/B is multi-byte, then separate bytes with spaces like so: "s/20\ 0A/00/g". Show Sample Output


    2
    xxd -p source | fold -w2 | paste -sd' ' | sed "s/A/B/g" | xxd -p -r > destination
    hincor · 2015-05-26 18:29:48 0
  • Finds all (not just adjacent) repeated lines in a file. Show Sample Output


    0
    LC_ALL=C sort file | uniq -c | sort -n -k1 -r
    drmaciver · 2010-03-23 12:09:04 0
  • range context (-A -B) search, with exclusion of vcs directories Show Sample Output


    0
    pcregrep -r --exclude_dir='.svn' --include='.*jsp$' -A 2 -B 2 --color "pHtmlHome" .
    hute37 · 2010-12-09 15:26:07 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: