While coding for the pi2jamma project and the regamebox distribution I need some helpers for text file handling.
grep -n "searchtext" file
- gives the column number of a given searchtext
sed -n "startnumber, endnumber p" file
gives you the snippet out of a text file.
sed -n "startnumber, endnumber p" file >> next_file
put stuff into next file.
Same is possible with sed in a script
start=$(sed -n '/search1/=' file)
end=$(sed -n '/search2/=' file)
sed -n "$start,$end p" file
or delete this area
sed -n "$start,$end d" file
or delete until file end
end_file=$(wc -l file)
sed -n "$start,$end_file d" file