Pages tagged with sed

I'm still in the process of tagging pages that were migrated from the old site, so for now you're best off using the search engine rather than relying on the tags.

  • Text manipulation - cut, awk and sed - Tokenize strings using cut If you know the exact delimiter (e.g. a tab) you can use cut. The format is as follows: cut -d[delimiter] -f[field_number] [filename] Where [delimiter] is the delimiter, [field_number] is the number of the field we want ...
  • Newline conversion from DOS/Windows to Unix/Linux - To convert DOS/Windows newlines (CRLF) to Unix/Linux newlines (LF): sed 's/^M$//' Important: To generate the ^M type ctrl-v-m, not the ^ character followed by M.
  • Escape spaces with sed - When dealing with file paths, you may need to escape spaces. You can do this using sed. #!/bin/sh p = "/var/lib/vmware/Virtual Machines" echo $p q = $(echo $p | sed 's/ /\\ /g') echo $q Output: /var/lib/vmware/Virtual Machines /var/lib/vmware/Vi...
  • Find and replace - Notes on how to use the find command to find and replace text. Index Delete everything up to the first occurence of a regexp Keep everything between <START> and <END> Find and replace over multiple lines with sed Find and replace ...
  • Extract filenames from file - grep for word in file | remove spaces | remove unwanted text | do op on file grep whatever whatever.log | sed 's/ /\\ /g' | sed 's/whatever//g' | xargs ls -l Example: List infected files clamscan -r -lclamscan.log / recursively scans all files and...

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top