Skip to content

Samyang7/Speed_sed_command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Description

Sed is a very complex program which has many commands. It is a important Unix/Linux tool. we implement a few of the most important commands of sed. Speed is a POSIX-compatible subset of sed with extended regular expressions (EREs). The Speed is implemented in Perl

Supported Command 1

requirement

  • speel.pl will be given a single Speed command as a command-line argument.
  • The Speed command will be one of 'q', 'p', 'd', or 's'. The only other command-line argument possible is the -n option.
  • speed.pl need only read from standard input.
  • Speed command can optionally be preceded by an address specifying the line(s) they apply to. This address can either be line number or a regex. line number is a positive number and regex is delimited with slash / characters

q - quit command

The Speed q command causes speed.pl to exit
example:
seq 500 600 | ./speed.pl '/^.+5$/q'
500
501
502
503
504
505

p - print command

The Speed p commands prints the input line
example:
seq 7 11 | ./speed.pl '4p' 7
8
9
10
10
11

d - delete command

The Speed d commands deletes the input line
example:
seq 11 20 | ./speed.pl '/[2468]/d'
11
13
15
17
19

s - substitute command

The Speed s command replaces the specified regex on the input line. The substitute command can followed optionally by the modifier character g
example:
seq 1 5 | ./speed.pl 's/[15]/zzz/'
zzz
2
3
4
zzz

-n command line option

The Speed -n command line option stops input lines being printed by default. -n command line option is the only useful in conjunction with the p command.
example:
seq 2 3 20 | ./speed.pl -n '/^1/p'
11
14
17

Supported Command 2

requirement

  • In additional to the previous requirement, $ can be used as an address.
  • Speed commands can optionally be preceded by a comma separated pair of address specifying the start and finish of the range of lines the command applies to.
  • substitue regex are not always delimited with slash / characters. whatever the delimiter is, it will not appear in regexes.

s - substitute command

any non-whitespace character may be used to delimit a substitute command
example:
seq 1 5 | ./speed.pl 's?[15]?zzz?'
zzz
2
3
4

multiple command

multiple Speed commands can be supplied separated by semicolons ; or newlines
example:
seq 1 20 | ./speed.pl '/2$/,/8$/d;4,6p'
1
9
10
11
19
20

Language

Perl

How to use

clone the speed.pl to the local computer and use as filter terminal command like example

About

stimulation for 'sed' command using perl

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages