Useful tips for linux

1 minute read

Among the various commands available in Linux, we have summarized useful things.

Ctags

Ctags is a programming tool that generates an index (or tag) file of names found in source and header files of various programming languages. Depending on the language, functions, variables, class members, macros and so on may be indexed. These tags allow definitions to be quickly and easily located by a text editor, a code search engine, or other utility. Alternatively, there is also an output mode that generates a cross reference file, listing information about various names found in a set of language files in human-readable form.

Link : Ctags wiki

Creating ctags file

# Ctags (-R option might not work in AIX)
ctags -f $HOME/src/ctags -R $HOME/src

# Ctags for AIX
ctags -w -f $HOME/src/ctags \
    /usr/include/*.[c,h] \
    $HOME/src/admin/*.[c.h] \
    $HOME/src/common/*.[c.h] \
    $HOME/src/spp/*.[c.h]

Add ctags to .vimrc

set tags+=${HOME}/src/tags

Get any key event

function pa() {
    read -n1 -r -p "Press any key"
}

Grep

  • ‘-i’ : Ignore case distinctions in both the PATTERN and the input files.
  • ‘-e’ : same as egrep
  • ‘-v’ : Invert the sense of matching, to select non-matching lines.
  • ‘-l’ : list the matching files
  • ‘-A’ : Print NUM lines of trailing context after matching lines.
  • ’–color’

Find

# Find recently modified c files within 1 day
find . -name "*.[c,h]" -mtime 1 | xargs -altr

Watch

# Monitoring
watch -d -n 1 'date'

Leave a comment