GNU sed version 4.1.5 seems to fail with International chars. Here is my input file:
Gras Och Stenar Trad - From Moja to Minneapolis DVD [G2007DVD] 7812 | X
Gras Och Stenar Trad - From Möja to Minneapolis DVD [G2007DVD] 7812 | Y
(Note the umlaut in second line.)
And when I do
sed 's/.*| //' < in
I would expect to see only the X and...
I have a ~23000 line sql dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that I want.
Does anyone know a unix command (or series of commands) to extract all lines from...
Most of my users have email addresses associated with their profile in /etc/passwd. They are always in the 5th field, which I can grab, but they appear at different places within a comma-separated list in the 5th field.
Can somebody give me a regex to grab just the email address (delimeted by commas) from a line in this file? (I will b...
I want to programmatically edit file content using windows command line (cmd.exe). In *nix there is sed for this tasks. Is there any usefull equivalent in windows?
Edit: I am looking for native command line solution.
...
I want to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task I normally use a small bash script with sed to re-write the file.
How do I get sed to replace just the first occurrence of a string in a file rather than replacing the every occurrence?
If I use
se...
How do I escape '<' and '>' character in sed.
I have some xml files which needs some text between the tags to be replaced. How do I escape the '>' and '<' characters.
The problem with > and < is it has special meaning in the shell to redirect the output to a file. So backslash doesn't work.
...
What GNU/Linux command-line tool would I use for performing a search and replace on a file?
Can the search text, and replacement, be specified in a regex format?
...
I have a bunch of java files from which I want to remove the javadoc lines with the license [am changing it on my code].
The pattern I am looking for is
^\* \* ProjectName .* USA\.$
but matched across lines
Is there a way sed [or a commonly used editor in Windows/Linux] can do a search/replace for a multiline pattern?
...
Hi.
I need to use sed to convert all occurences of ##XXX## to ${XXX}. X could be any alphabetic character or '_'. I know that I need to use something like:
's/##/\${/g'
But of course that won't properly, as it will convert ##FOO## to ${FOO${
Any takers?
- Don
...
Hi,
I need to to iterate over the files in a directory and perform the following replacement.
Before:
Hello ${USER_NAME}, you live at
${HOME_ADDRESS}. It is now ${TIME}
After:
Hello ${userName}, you live at
${homeAddress}. It is now ${time}
The number of different tokens that appear within ${} is large, so it's not real...
If I have a list of data in a text file seperated by a new line, is there a way to append something to the start, then the data, then append something else then the data again?
EG a field X would become new X = X;
Can you do this with bash or sed or just unix tools like cut?
EDIT:
I am trying to get "ITEM_SITE_ID :{$row['ITEM_SITE_ID...
Hi, I am using sed from cygwin on Windows to do some substitutions in text files. Everything works fine for normal (ANSI) files, but it doesn't do anything for utf-16 files (no substitutions are made). Do you know how I can make it work for both types of files at the same time?
...
I have a directory full of files and I need to pull the headers and footers off of them. They are all variable length so using head or tail isn't going to work. Each file does have a line I can search for, but I don't want to include the line in the results.
It's usually
*** Start (more text here)
And ends with
*** Finish (more te...
I would like to know if there is any easy way to print multiple emails(about 200) so that they continue on as opposed to printing one per page. I have tried with thunderbird and evolution and this does not seem possible. Would concatenating the individual mail files work or are there other unix utilities that could do this? WOuld sed or ...
I need to do the following for hundreds of files:
Append the name of the file (which may contain spaces) to the end of each line in the file.
It seems to me there should be some way to do this:
sed -e 's/$/FILENAME/' *
where FILENAME represents the name of the current file. Is there a sed variable representing the current filename? ...
My log file is:
Wed Nov 12 blah blah blah blah cat1
Wed Nov 12 blah blah blah blah
Wed Nov 12 blah blah blah blah
Wed Nov 12 blah blah blah blah cat2
more blah blah
even more blah blah
Wed Nov 12 blah blah blah blah cat3
Wed Nov 12 blah blah blah blah cat4
I want to parse out the full multiline entries where cat is fo...
I need to repeatedly remove the first line from a huge text file using a bash script.
Right now I am using sed -i -e "1d" $FILE - but it takes around a minute to do the deletion.
Is there a more efficient way to accomplish this?
...
Let me start off by saying that I know there is probably a much simpler way to do this.
But this is what i have and yes hopefully I can make some improvements and/or simplifications at the end.
Goal as of this moment
To double space the output stored in the $tmp variable below and individually number each line. Doing this should give m...
I'm looking for a SimpleGrepSedPerlOrPythonOneLiner that outputs all quotations in a text.
Example 1:
echo “HAL,” noted Frank, “said that everything was going extremely well.” | SimpleGrepSedPerlOrPythonOneLiner
stdout:
"HAL,"
"said that everything was going extremely well.”
Example 2:
cat MicrosoftWindowsXPEula.txt | SimpleG...
I need to find a faster way to number lines in a file in a specific way using tools like awk and sed. I need the first character on each line to be numbered in this fashion: 1,2,3,1,2,3,1,2,3 etc.
For example, if the input was this:
line 1
line 2
line 3
line 4
line 5
line 6
line 7
The output needs to look like this:
1line 1
2line 2...