fed - file editor for filtering and transforming text, file-wide.
fed [OPTION]... [COMMAND]... [input-file]... # Replace first occurance of 'foo' and 'bar' (and all between) with space. fed 's/foo.+?baz/foo baz/' text_*.txt # Strip comments from config files, each time show diff and ask: fed -a -d 'r/\s*#.+?$/m' *.conf # Remove HTML links. fed -c 's{<a.+?>(.+?)<\\\/a>}{$1}sg' page*.html
This is an Alpha release. It may be unstable. It may corrupt your files.
Use with caution, for evaluation purposes only.
Fed is a replace/filter utility, working on per-line or per-file basis, across multiple files, even going recursively into directories.
It aims to provide easy access to some functionality of sed, awk and Perl.
By default it will replace files in-place, so you do not have to pipe/move anything.
You can control the edit process either by having changed files written under different name, or by inspecting changes (with diff) and accepting them manually.
Following commands are supported: s (substitute), tr (transcode), p (pipe), r (remove), and m (match). Following separators are supported: //, {}, [].
Many commands can be provided in a row, they will all be applied one after another, each working on the output from previous one.
Please see App::Fed::Cookbook for how those can be applied to real-life situations.
Substitute, according to given expression.
Transcode, according to given expression.
Pipe matched content into shell command, and use it's output as replacement.
Remove parts, that match the regular expression.
Match parts of the filename and remove anything else.
Evaluate EXPRESSION as Perl code, before replacing.
Enable global matching.
Do case-insensitive pattern matching.
Enable matching in multi-line mode.
That is, change "^" and "$" from matching the start or end of file to matching the start or end of any line.
Change "." to match any character whatsoever, even a newline, which normally it would not match.
Enabling 'm' and 's' as "/ms", they let the "." match any character whatsoever, while still allowing "^" and "$" to match, respectively, just after and just before newlines within the string.
Ask, before writing anything.
Write anything only, if any changes ware made.
Show diff between original and modified content, before writing changes.
By default, program will not ask or wait for confirmation, just describe the changes and continue. If you want to be able to inspect and confirm changes, use with combination with -a.
This is useful to be able to quickly inspect - post-mortem - what has been done.
What comparison command to run, defaults to: diff.
Output a short help and exit.
When used with -P or -S, fed will move the file first, then copy it to the old name, and finally modify moved file.
This preserves hard links, ownership and other attributes.
If file is changed in-place, the option is silently ignored.
Do not do anything, just pretend and describe what would be done.
This option overwrites -a (with a warning).
Output nothing, and if, then only to STDERR.
Process directories recursively. If this option is not enabled, those will be ignored (silently, unless in verbose mode).
Instead of doing the change in-place, save changed file to a copy with PREFIX added to the name.
Instead of doing the change in-place, save changed file to a copy with SUFFIX added to the name.
Explain what is being done.
Display version info and exit.
This command uses Perl Regular Expressions. It will understand everything, that the version of Perl on which it runs will accept.
Probably. None known at the moment.
Please report using CPAN RT or email to the author.
Those are some interesting potential features, that may be implemented in future version. If you need them, please notify the author.
Do not cross file system boundaries.
Enable (or disable) use of color in the output.
Requires Term::ANSIColor.
Use recipe named RECIPY from the APP::Fed::Coocbook.
Run 'Command file' after applying changes.
Command file
If Command returns non-zero exit status, changes will be cancelled.
fed will create a tmp file containing modified content, and use it for test, before changing the original.
On completion, dump summary of what was done.
ack(1), awk(1), ed(1), grep(1), tr(1), perlre(1), sed(1)
Copyright (C) 2011 Bartłomiej /Natanael/ Syguła
This is free software. It is licensed, and can be distributed under the same terms as Perl itself.
To install App::Fed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Fed
CPAN shell
perl -MCPAN -e shell install App::Fed
For more information on module installation, please visit the detailed CPAN module installation guide.