Commands tagged output redirection (3)

  • In this case I'm selecting all php files in a dir, then echoing the filename and piping it to ~/temp/errors.txt. Then I'm running my alias for PHPCS (WordPress flags in my alias), then piping the PHPCS output to grep and looking for GET. Then I'm piping that output to the same file as above. This gets a list of files and under each file the GET security errors for that file. Extrapolate this to run any command on any list of files and pipe the output to a file. Remove the >> ~/temp/errors.txt to get output to the screen rather than to a file. Show Sample Output


    1
    for f in *php; do echo $f >> ~/temp/errors.txt; phpcsw $f | grep GET >> ~/temp/errors.txt; done
    topher1kenobe · 2023-04-12 14:17:14 367
  • Write script or commands in notepad/Editplus/MS word etc, copy the contents, type the above command and click on enter now, paste by right click-ing the mouse. Entire contents in the clip-board gets pasted now again click on Enter to go to new line/next line. Press Ctrl+D to close/save the file. Not always required to vi to create a new file.


    -2
    cat > file_name
    michaelrozar17 · 2012-03-27 11:38:09 4

  • -2
    sed -n '/jan\|Jan\|JAN\|JAn\|jAn\|jAN\|jaN/p' data.txt > jan-only-data.txt
    Kali_Root · 2013-11-15 20:23:53 8

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


Check These Out

enable all bash completions in gentoo
enable each bash completion that you have installed at your system, that's very nice ;)

check open ports without netstat or lsof

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Show git branches by date - useful for showing active branches
This fixes a bug found in the other scripts which fail when a branch has the same name as a file or directory in the current directory.

tail: watch a filelog
-f file(s) to be monitorized -n number of last line to be printed on the screen in this example, the content of two files are displayed

list files recursively by size

Remove all old kernels
http://askubuntu.com/questions/89710/how-do-i-free-up-more-space-in-boot

Daily watch "question pour un champion" (French TV show)
kaffeine could be replaced by any player able to read mms stream

Clear cassandra snapshots that are older than 30 days
Better than: $ nodetool clearsnapshot

Generate a random password 30 characters long
This command is similar to the alternate, except with head(1), you can pick as many passwords as you wish to generate by changing the number of lines you wish to preview.


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: