Tagged Questions
7
votes
3answers
619 views
Can grep output only specified groupings that match?
Say I have a file:
# file: 'test.txt'
foobar bash 1
bash
foobar happy
foobar
I only want to know what words appear after "foobar", so I can use this regex:
"foobar \(\w\+\)"
The parenthesis ...
4
votes
2answers
126 views
How to search and replace multiple needles by one word via one expression?
Assume you have a text file:
foo fnord bar
bizz foo poit
And now I would want to replace both "foo" and "bar" into "narf".
I know I could use:
sed -e 's/foo/narf/g' -e 's/bar/narf/g' fileName
...
9
votes
8answers
667 views
There must be a better way to replace single newlines only?
I am in the habit of writing one line per sentence because I typically compile things to LaTex, or am writing in some other format where line breaks get ignored. I use a blank line to indicate the ...
3
votes
3answers
387 views
Finding text between two specific characters or strings
Say I have lines like this:
*[234]*
*[23]*
*[1453]*
where * represents any string (except a string of the form [number]). How can I parse these lines with a command line utility and extract the ...
3
votes
0answers
127 views
How to use regrex with AWK for string replacement in this example? [closed]
Possible Duplicate:
How to use regrex with AWK for string replacement in this example?
Suppose there is some text from a file:
(bookmarks
("Chapter 1 Introduction 1" "#1"
("1.1 Problem ...
1
vote
3answers
623 views
How to use regrex with AWK for string replacement in this example?
Suppose there is some text from a file:
(bookmarks
("Chapter 1 Introduction 1" "#1"
("1.1 Problem Statement and Basic Definitions 23" "#2")
("Exercises 31" "#30")
("Notes and References 42" "#34"))
)
...