I know little about sed, I know nothing about awk.
I have try this :
my_function () {
sed -n '/^$1/,$p $2 | sed -n '/^$3/,p' | sed '/$5/ q'
}
In the following text sample :
I find your description cryptic.
Please provide a few sample input files, sample arguments to your function for those input files, and the output you want to have produced by your function for each of those samples.
You have sed in the title of this thread, but it sounds like this might be easier using awk. Will you accept a solution using something other than sed?
systemd is a system management daemon designed exclusively for the Linux kernel.
In the Linux startup process, it is the first process to execute in user land; therefore, it is also the parent process of all child processes in user land.
systemd was developed for Linux to replace the init system inherited from UNIX System V and Berkeley Software Distribution (BSD) operating systems.
Like init, systemd is a daemon that manages other daemons.
All daemons, including systemd, are background processes.
systemd is the first daemon to start (during booting) and the last daemon to terminate (during shutdown).
Lennart Poettering and Kay Sievers, the software engineers who initially developed systemd,[1] sought to surpass the efficiency of the init daemon in several ways.
They wanted to improve the software framework for expressing dependencies; to allow more processing to be done concurrently or in parallel during system booting; and to reduce the computational overhead of the shell.
Now calling the function with these parameters
my_function "In the Linux startup process" "./file_text.txt" "Like init" "manages" "ways"
This find $1 in file $2, and then find $3 before $5.
This give a few lines beginning with $3 and last line ending with $5
Like init, systemd is a daemon that manages other daemons.
All daemons, including systemd, are background processes.
systemd is the first daemon to start (during booting) and the last daemon to terminate (during shutdown).
Lennart Poettering and Kay Sievers, the software engineers who initially developed systemd,[1] sought to surpass the efficiency of the init daemon in several ways
Now searching with $4 = manages in the first line will return true
and searching with $4 = background in the first line will return false
Thank you for taking time to help me.