New answers tagged


In vim, :goto 6 or, 6go will move the cursor to the graphem that contains the 6th byte in the current buffer. If the offset points to a newline character, it will position the cursor at the end of the corresponding line (on you sample, 40go and 41go will bring the cursor to the same position).


Another way using od -- od -An -c -j 5 -N1 file i


Cut is what you are looking for. cut -b6 file1.txt This shows you the 6th byte...per line of the file. I think you only want the 6th byte so you can use something like head head -n1 file1.txt | cut -b6 Voila.


From the POSIX specifications for ex: Implementations wanting to provide a counterpart to the next command that edited the previous file have used the command prev[ious], which takes no file argument. POSIX.1-2008 does not require this command. So, in most implementations, :prev will do what you want. (That is, most implementations of ex that I've ...


Given the vi tag on this question, and the fact that I've found that automated file editing with POSIX-compliant ex commands gets short shrift on this site compared to the plethora of advice on sed, awk, grep and even Perl, here is a POSIX-compliant ex command that will perform the desired filtering: ex -sc 'g/.*\(on line\)/s//\1/ | .w!>>output q!' ...


If your grep doesn't support the -o option: sed 's/^.*\(on line\)/\1/' temp.text > out.txt Or if you only want the lines that contain on line: sed -n 's/^.*\(on line\)/\1/p' temp.text > out.txt Note that if there are several occurrences of on line, it prints the portion of the line that starts with the rightmost occurrence of it. For the leftmost ...


start cmd:> awk 'lines[$0]++ == 0' input Hi how are you hello today is monday I am fine


This is an easy job for sort, use the unique (-u) option of sort: % sort -u file1.txt hello Hi how are you I am fine today is monday To save it in file2.txt: sort -u file1.txt >file2.txt If you want to preserve the initial order: % nl file1.txt | sort -uk2,2 | sort -k1,1n | cut -f2 Hi how are you hello today is monday I am fine


Try this: grep -o 'on line .*' temp.txt > out.txt The -o parameter makes grep only output the matching part of the line, which is what you want.


Use the -o option of grep to select only the desired portion, in your case use pattern on line .* to select the portion starting from on line till the end of the line(s): % grep -o 'on line .*' temp.txt >new.txt % cat new.txt on line jhkjhvjdbvjvbvbdjkvn on line fdgdgdgdd on line safffasffaf on line adaddsd

Top 50 recent answers are included