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

mod rewrite - Using "?" when rewriting the URL -

.htaccess: Transfer name to index.php if not directory public -

Admob integration with pygame in android -