Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 36502

Manipulation or examining of text by programs, scripts, etc.

1
vote
You could also use pcregrep: pcregrep -M '234238.*(\n((?!Entry).)*)*' inputfile This would produce all lines starting from the one containing 234238 until it encounters one that contains the word E …
answered Mar 31 '14 by devnull
6
votes
Using sed isn't quite as straight-forward as mentioned by Joseph R.. However, you could say: sed '/./{H;d;};x;s/\n/={NL}=/g' inputfile | \ sed -e 's/^={NL}=//' -e '1!G;h;$!d' | \ sed G | sed 's/={NL …
answered Feb 16 '14 by devnull
3
votes
You could use sed: sed -n '8000p;' filename If the file is large, then it'd be better to quit: sed -n '8000p;8001q' filename You could similarly quit reading the entire file using awk or perl to …
answered May 17 '14 by devnull
32
votes
Specify the sort keys separately with the criteria: sort -k1,1nr -k2,2 inputfile This specifies that the first key is sorted numerically in reverse order while the second is sorted as per the defau …
answered Mar 31 '14 by devnull
40
votes
You could use sed. The following would remove lines that are 3 characters long or smaller: sed -r '/^.{,3}$/d' filename In order to save the changes to the file in-place, supply the -i option. If …
answered Apr 5 '14 by devnull
6
votes
It seems that the apt-get lines have a preceding whitespace. Saying: sed -e :a -e '$!N;s/\n / /;ta' -e 'P;D' inputfile should produce the desired result. Alternatively, you can also use paste: p …
answered Oct 7 '13 by devnull
5
votes
As mentioned in the comments, you can't achieve what you want using sort alone. You could cut the input file, feed relevant part to sort, and paste those. $ paste -d' ' <(cut -d' ' -f1 input | sort …
answered Feb 16 '14 by devnull
3
votes
Your file contains CR+LF line ending. (You can say cat -vet inputfile to figure that. Carriage returns would show up as ^M in the output.) The following demonstrates the effect of line endings on t …
answered Feb 26 '14 by devnull
33
votes
Yes, it is possible with sed: sed '/pattern/a some text here' filename An example: $ cat test foo bar option baz $ sed '/option/a insert text here' test foo bar option insert text here baz $
answered Mar 24 '14 by devnull
6
votes
One way would be to use awk and paste: paste -sd'\t' <(awk 'NR%2' inputfile) <(awk '!(NR%2)' inputfile) The idea is to get odd and even lines separately and paste those. For your input, it'd produ …
answered Feb 13 '14 by devnull
1
vote
Using sed you could say: sed -n '/Version/{s/^[^0-9]*//;s/\([^.]*\.[^.]*\)\./\1/p}' filename For your sample input, it'd produce: 2.46576.8.332 As mentioned in the comment, it isn't quite clea …
answered Mar 18 '14 by devnull
1
vote
You could use perl. Saying: perl -lanE 'mkdir substr(@F[1],0,4) . substr(@F[0],0,2)' studentInfo.txt would create the desired directories.
answered Apr 21 '14 by devnull
3
votes
You've already tagged the question awk, so make use of it: awk '{if (NF>=2) {print > "LIST-ok.txt"} else {print > "LIST-notok.txt"}}' filename Another way of saying the same would be to make use of …
answered Feb 23 '14 by devnull
6
votes
You could use perl. Straight from the faq -- quoting from perldoc perlfaq6: How do I substitute case-insensitively on the LHS while preserving case on the RHS? Here's a lovely Perlish solution by L …
answered Apr 20 '14 by devnull
7
votes
You could use awk: awk '{a[int($1)]++}END{for (i in a) {print a[i], i}}' inputfile If you want the output to be sorted, pipe the output to sort: awk '{a[int($1)]++}END{for (i in a) {print a[i], i} …
answered May 2 '14 by devnull