Linux

Finding files and directories in Linux.

Finding files and directories in Linux. Case-insensitive file searching with the locate command It’s easy to perform a case-insensitive file search with the Linux locate command: just add the -i flag. To search my entire filesystem for files and directories that contain the string typeahead, just use this command: locate -i typeahead Case-insensitive file searching […]

Linux

How do I remove empty directories in Linux?

Update: 06/2023 This post is rather dated now. Simply use the find command instead. find /path/to/dir -empty -type d -delete And for empty files: find /path/to/dir -empty -type f -delete Old original post. You can use program called cleanlinks. The cleanlinks program searches the directory tree descended from the current directory for symbolic links whose […]

Linux

Removing lines of text with SED

This will remove a specific block of text between two pointers. sed ‘/<script type=”text\/javascript”/,/<\/script>/d’ <filename> ..will remove all text between <script…> and </script> (Including the <script> tags. Here is a short shell script to automate this for a bunch of files. #!/bin/bash # ALL HTML FILES FILES=”*.html” # for loop read each file for f […]

Linux

Linux chmod parameters explained

How to use chmod in Linux. chmod u+ = assign user permissions chmod g+ = assign group permissions chmod a+ = assign all permissions Some examples: Command: chmod u+wrx testfile.txt Result: -rwx—— 1 root root 0 Feb 5 16:53 testfile.txt Command: chmod g+wrx testfile.txt Result: —-rwx— 1 root root 0 Feb 5 16:53 testfile.txt Command: […]

Linux

Handy one line SED command howto

————————————————————————- HANDY ONE-LINERS FOR SED (Unix stream editor) Apr. 26, 2004 compiled by Eric Pement – pemente[at]northpark[dot]edu version 5.4 Latest version of this file is usually at: http://sed.sourceforge.net/sed1line.txt http://www.student.northpark.edu/pemente/sed/sed1line.txt This file is also available in Portuguese at: http://www.lrv.ufsc.br/wmaker/sed_ptBR.html FILE SPACING: # double space a file sed G # double space a file which already has […]