I am trying to clean up some data, and I would eventually like to put it in CSV form.
I have used some regular expressions to clean it up, but I'm stuck on one step.
I would like to replace all but every third newline (\n) with a comma.
The data looks like this.
field1
field2
field3
field1
field2
field3
etc..
I need it in
field1,...
I'd like to rename some files that are all in the same directory. The file name pattern used is Prefix_ddmmyy.tex with a european date format. For the sake of readability and the ordering I'd like to rename the files in a pattern Prefix_yymmdd.tex with a canonical date format.
Anyone ideas how I can do this automatically for a complete ...
How can I call awk or sed inside a c program? I know I could use exec(), but I don't want to deal with fork() and all that other nastiness.
...
I am trying to standardize my exports file. I need to remove all spaces and tabs between the first two fields and replace them with two tabs. I am using VI.
So I want to change
/vol/vol1/home1/xxx -rw=admin:app:admhosts
to
/vol/vol1/home1/xxx -rw=admin:app:admhosts
making the space equil to To two TABS.
I am using VI....
Problems
to get permissions
of each file in every folder
to find files
which have 777 permissions, and then
print the filenames with their paths
to a list
We can get permissions for files in one folder by
ls -ls
I do not know how you can get permissions of each file in every folder effectively.
How can you find files which have ...
I try to copy a command from history. How can I copy the 510th command? Please, see the data below. My bet is:
history | grep 510 | sed '1q;d' | awk '{print $2-$10}' | pbcopy
but the output is 0. I cannot understand the reason. What is wrong in the command?
505 find . -perm=750 -print0 | xargs -0 chmod 750
506 find . --perm=750...
I run the code gives me the following sample data
md5deep find * | awk '{ print $1 }'
A sample of the output
/Users/math/Documents/Articles/Number theory: Is a directory
258fe6853b1bfb2d07f512ff6bec52b1
/Users/math/Documents/Articles/Probability and statistics: Is a directory
4811bfb2ad04b9f4318049c01ebb52ef
8aae4...
What this question isn't asking is how to add a new line below or above every line which matches a pattern.
What I'm trying to do is add a new line between a pattern that exists on one line.
Here is an example.
before:
Monday:8am-10pm
after:
Monday:
8am-10pm
Thus in this case, insert new line after every 'Monday' patt...
Hello everyone,
I have a large collection of php files written over the years and I need to properly replace all the short open tags into proper explicit open tags.
change "<?" into "<?php"
I think this regular expression will properly select them :
<\?(\s|\n|\t|[^a-zA-Z])
which takes care of cases like
<?//
<?/*
but I am not s...
Hi, I'd like to change the following patterns:
getFoo_Bar
to:
getFoo_bar
(note the lower b)
Knowing neither foo nor bar, what is the replacement pattern?
I started writing
sed 's/\(get[A-Z][A-Za-z0-9]*_\)\([A-Z]\)/\1
but I'm stuck: I want to write "\2 lower case", how do I do that?
Maybe sed is not adapted?
...
Given this data
34 foo
34 bar
34 qux
62 foo1
62 qux
78 qux
I want to replace the string at 2nd column into "" if it is "qux".
Resulting:
34 foo
34 bar
34
62 foo1
62
78
How do you do that with sed? In particular the data is very big with ~10^7 lines
...
I am using shell script. How to copy one file content to another file using "sed". I have to use only sed to complete this copy. can anyone help me?
Thanks in advance
Sudha
...
The file is initially
$cat so/app.yaml
application: SO
...
I run the following command. I get an empty file.
$sed s/SO/so/ so/app.yaml > so/app.yaml
$cat so/app.yaml
$
How can you use SED to edit the file and not giving me an empty file?
...
Not how to insert a newline before a line. This is asking how to insert a newline before a pattern within a line.
For example,
sed 's/regexp/&\n/g'
will insert a newline behind the regexp pattern.
How can I do the same but in front of the pattern?
Here is an example input file
somevariable (012)345-6789
Should become
some...
HI
I am using SED to find total number of lines of txt file.
want to assign the output of sed to variable BAT file.
I used the below code to do this
for /f %%a in (`"sed15 -n $= TEST.TXT"') do set linenum=%%a
and I get the error message
"the system cannot find the file `"sed15 -n $= TEST.TXT"'.
how can we solve this?
...
I'm reading from a line that's about 500 characters. How can I get sed to, instead of replacing that string with something, replace the rest of the line with something?
In short, I want to remove all the text around a specified string. Deleting columns with awk won't work, because there is an indeterminate amount of characters before and...
Given:
file a.txt containing many millions
of lines (say, one sentence per line) (2.6 gb!)
file b.txt containing 830k lines with pairs "[word1] [word2]"
Question:
how to perform the most efficient replacement of each word1 by word2 for every of 830k tuples (w1, w2) in the huge text file?
Naive methods like sed, perl, python etc. wo...
I have a text file and it requires some formatting.
I know that if you want to add a blank line above every line that matches your regexp, you can use:
sed '/regexp/{x;p;x;}'
But I'd like to add a blank line, not one line above, but two lines above the line which matches my regexp.
The pattern I'll be matching is a postal code, in th...
I'm trying to parse various info from log files, some of which is placed within square brackets. For example:
Tue, 06 Nov 2007 10:04:11 INFO processor:receive: [someuserid], [somemessage] msgtype=[T]
What's an elegant way to grab 'someuserid' from these lines, using sed, awk, or other unix utility?
...
I'm writing a shell script to edit
Change-Set attributes of aegis. The
command I'm using is:
aegis -Change_Attributes -Edit
which opens up a vi editor to carry
out the changes. I want to do a search
and replace:
s/brief_description \= \"none\"\;/brief_description \=
\"test\"/g
Can I pass these directly to th...