To open files found with grep in Sublime Text, run the following command subl $(grep -irl “search for text” .) Where i = case insensitive r = recursive l = only file names Be sure to include the l flag, otherwise you’ll open a bunch of new files with no relation to what you’re […]
Category: Linux
Linux: Get directory size recursively
To see the size of a directory and all of its contents, run the following: du -sh /path/to/directory
Linux, get number (octal) file permission
To get the number (octal) file permission use the following: stat -c “%a” your.file
Find command associated with PID (process id)
To find the command / more information associated with a specific process id (PID), do the following: cat /proc/[pid]/cmdline
Cron Job: Run rails rake task in shell script
To run a rake task within a shell script using a cron job, do the following: First, specify the shell at the top of your .sh script #!/bin/sh Then, change your directory to your rails application in your .sh script cd /home/user/app/current Now, you need to manually define your PATH within the script: […]
Grep count all occurrences found
You can use Grep to count all occurrences of a string with the following cat * | grep -c [search] .
chmod only files or directories recursively
To chmod only files or directories recursively, do the following: For files: find . -type f -exec chmod 644 {} ; For directories find . -type d -exec chmod 755 {};
Grep list only unique filenames
To list unique filenames using grep, do the following: grep -irl “search-term” . Notice the ‘l’ flag, short for –files-with-matches, defined as “Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match.” The i flag just makes […]
Install FFMPEG on Ubuntu
If you run into the following error when installing FFmpeg on Ubuntu Package ffmpeg is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package ‘ffmpeg’ has no installation candidate You can do the following to […]