Using bash variables for range in sed -


sed -n '5,10 p' < /proc/cpuinfo  

prints 5-10 lines of file /proc/cpuinfo

i want use

start=5 end=10 sed -n '$start,$end p' < /proc/cpuinfo 

so can change values of start , end form script.

you need use double quotes variable expansion:

start=5 end=10; sed -n "$start,$end p" < /proc/cpuinfo 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -