back       next

One Liners

Get the query string using javascript

To get the query string of a page using javascript, use the below code snippet:

window.top.location.search.substring(1);

Search and Edit Files with Certain Text

Here's a quick way to edit all files whose contents contain a given string:

files=""; for i in `find . -type f -print`; do files="$files `grep -l <text> $i`"; done; vi $files
  1. For all file names in the current directory, including those in subdirectories, assign each in turn to the variable i.
    for i in `find . -type f -print`;
  2. For each of the files we found, run the grep command to search the file provided by the $i variable.
    do files="$files `grep -l <string> $i`";
  3. Edit the found files with the vi editor.

Syndicate content