I'd like to use a sed script like this
#n
/^TODO/,/^$/p
except that sed should stop printing the range after it comes across two consecutive blank lines, rather than just one blank line. Then it should continue scanning for the next range of interest. In other words, the end of range of interest is defined by two blank lines. I'm not ...
I want a sed script that I can use for 1) finding instances, and 2) printing this string:
<bean:write name='iframesrcUrl'/>
<bean:write name="iframesrcUrl"/>
<bean:write name="currentPage" property="title" filter="false"/>
or similar. name and property values can differ. property and filter attributes are optional. Both single quotes...
How do I display data from the beginning of a file until the first occurrence of a regular expression?
For example, if I have a file that contains:
One
Two
Three
Bravo
Four
Five
I want to start displaying the contents of the file starting at line 1 and stopping when I find the string "B*". So the output should look like this:
One
T...
I'm trying to parse json returned from a curl request, like sp:
curl 'http://twitter.com/users/username.json' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
I have it set working where it splits the json into fields, i.e. the above returns
% ...
"geo_enabled":false
"friends_count":245
...
Greetings,
While I've gotten many answer off this site, this is my first question, and I'm kinda excited about it... :)
I've written a script that cleans up .csv files, removing some bad commas and bad quotes (bad, means they break an in house program we use to transform these files) using sed:
# remove all commas, and re-insert t...
I'm looking for very simple template script for building JS files. It should do only one thing: include one file to another.
Template (main.js)
/*> script.js */
var style = "/*> style.css */";
script.js
var my_script;
style.css
html, body {margin:0; padding:0}
.my-style {background: #fffacc}
Output
var my_script;
var style =...
Hi
Is there any script that would transform a tab delimited data file into libSVM data format? For an example my unlabelled data:
-1 9.45 1.44 8.90
-1 8.12 7.11 8.90
-1 8.11 6.12 8.78
and I would like to append each value with a label:
-1 1:9.45 2:1.44 3:8.90
-1 1:8.12 2:7.11 3:8.90
-1 1:8.11 2:6.12 3:8.78
I believe this can b...
The first command does work as expected but not the second one.
I want to add some text either at the beginning or the end.
# grep `date +'%y%m%d'` /var/log/mysqld.log
100101 10:56:00 mysqld started
100101 10:56:02 InnoDB: Started; log sequence number 1 2052750649
# sed 's/^/computer /g' < grep `date +'%y%m%d'` /var/log/mysqld.log
ba...
I have a variable with the contents "eth0 eth1 bond0", is there a way using sed or a similar tool to move anything matching bond.* to the beginning of the line?
...
I have a variable with the following contents: "a b c d e f g h i j k l", how would you go about adding a comma sign (,) after each third member so it looks like this: "a b c, d e f, g h i, j k l".
Initially all my variable data is stored in an array so if anyone knows how to directly manipulate the array, it would be great.
Thanks in ...
My script takes a file name in the form R#TYPE.TXT (# is a number and TYPE is two or three characters).
I want my script to give me TYPE. What should I do to get it? Guess I need to use awk and sed.
I'm using /bin/sh (which is a requirement)
...
Hello all
I need to reverse all string in text with 5 chars consecutive characters. For instance:
hello hi adams sde
abcde abs
Required output:
olleh hi smada sde
edcba abs
I used:
sed -n 's\(a-z]\)\([a-z]\)\([a-z]\)\([a-z]\)\([a-z]\)/\5\4\3\2\1/p'
It reverses needed strings except "adams". Please help me fix this.
...
Using sed or similar how would you extract lines from a file? If I wanted lines 1, 5, 1010, 20503 from a file, how would I get these 4 lines?
What if I have a fairly large number of lines I need to extract?
If I had a file with 100 lines, each representing a line number that I wanted to extract from another file, how would I do that?
...
How do I combine two specific adjacent lines in a large text file into one line using sed? For example I want to combine line numbered 2001891 and 2001892 into one line, and write it back to the file at the same line location (meaning line 2001893 and below will get shifted up)?
I've googled around for tutorials and manuals on sed but ...
I want to add the following line to /etc/my.cnf
server-id=1789051
The line may or may not be there.
If it is there, it is usually server-id=1
If my IP is 192.178.90.51 then the server id should be 1789051
I want to know if a shell script or a command can do it.
...
I know this is a borderline case whether it really belongs to stackoverflow or superuser, but as it seems there are quite a few 'editing code' questions over here, I am posting it on SO.
I have a pile of XML files that someone in their infinite wisdom have decided to explode to a multiple files using the tags, which in result makes deb...
I have a 200 Mb text file and for every line need to swap the 3rd and 4th characters with the 6th and 7th characters, so that
1234567890
would become
1267534890
I am using Windows XP with PowerShell installed. Also installed is Cygwin and UnxUtils so have access to versions of cut, sed, awk, grep, etc. There is no delimiter in the fi...
i have some xml files in linux
a="xx
xx
xx"
b="y
y
y"
How to replace the content and becomes
a="xx\n\xx\nxx"
b="y
y
y"
where attribute b is not replace
i have try this but how to support multi files and replace the attribute "a" only using sed or awk command; (not use xslt)
sed ':a;N;$!ba;s/\n/\\n/g' abc.xml
...
echo "sed -i 's/NULL/\\N/g' ".$_REQUEST['para'].".sql";
The above statement works. But it fail when I use it in exec like this...
exec("sed -i 's/NULL//\/\/\N/g' ".$_REQUEST['para'].".sql");
...
OK I found this question:
http://stackoverflow.com/questions/876446/how-do-i-delete-a-matching-line-the-line-above-and-the-one-below-it-using-sed
and just spent the last hour trying to write something that will match a string and delete the line containing the string and the line beneath it (or a variant - delete 2 lines beneath it).
...