We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Middle of a Text File
Middle of a Text File
+ 0 comments while read line; do cat $file | sed -n '11,21p' done
+ 0 comments 1.
head -22 | tail -11
2.
awk 'NR==12, NR==22 {print $0}'
https://www.geeksforgeeks.org/awk-command-unixlinux-examples/
3.
sed -n '12,22p'
+ 0 comments while read lines; do echo $lines >> file.txt done (head -n 22 | tail -n 11) < file.txt
+ 0 comments sed -n '12,22p'
This script uses the sed command to print out a range of lines from the input text. Here's what each part of the script does:
sed is a Unix command-line utility for manipulating text.
-n
is an option that tells sed not to print out every line it processes.'12,22p'
is a command that tells sed to print out only the lines between line 12 and line 22, inclusive. So, when you run the commandsed -n '12,22p'
,sed
reads in the input text, but only prints out lines 12 through 22.
+ 0 comments #!/bin/bash rm file.txt > stdout.tx 2> stderr.txt while read LINES; do echo $LINES >> file.txt done (head -n22 | tail -n11) < file.txt
Load more conversations
Sort 96 Discussions, By:
Please Login in order to post a comment