What are the differences between Perl, Python, AWK and sed?
Hello, just want to know what are the main differences among them? and the power of each language (where it's better to use it). Edit: it's not "vs." like topic, just information. ...
Hello, just want to know what are the main differences among them? and the power of each language (where it's better to use it). Edit: it's not "vs." like topic, just information. ...
I'm trying to replace every multiline import inside a Python source file.. So, the source goes like from XXX import ( AAA, BBB, ) from YYY import ( CCC, DDD, EEE, ... ) ...other instructions... and I'd like to get something like from XXX import AAA, BBB from YYY import CCC, DDD, EEE, ... ...other instructions... ...
Hi, I have several files containing this line Release: X I want to increment X in all the files. If X was constant between the files, I could have a bash script looping around the files and doing ($1 containing the former release number and $2 the new one, ie. $1 + 1) : sed 's/Release: '$1'/Release: '$2'/' <$file >$file.new Now,...
I have a skeleton text file with placeholder strings: blah blah blah blah $PLACEHOLDER_1$ blah $PLACEHOLDER_2$ and so on. Specific "form" of placeholders does not matter -- I may change them to whatever most comfortable for specific implementation. I have a bash script where I know values for placeholders, and I need to generate a ne...
In my bash script I have an external (received from user) string, which I should use in sed pattern. REPLACE="<funny characters here>" sed "s/KEYWORD/$REPLACE/g" How can I escape the $REPLACE string so it would be safely accepted by sed as a literal replacement? NOTE: The KEYWORD is a dumb substring with no matches etc. It is not sup...
Hello, I have a bat file that I should use to delete a part of one file and save into another one. I need to delete all the symbols between text "[aaa bbb]" and "[ccc ddd]". That is if I have the text: [aaa bbb] 1 2 3 [ccc ddd] I should have as output: [aaa bbb] [ccc ddd] Thank you EDIT: I would like to clarify the question. I sho...
I have an ascii file and in there somewhere is the line: BEGIN and later on the line: END I'd like to be able to remove those two lines and everything in between from a command line call in windows. This needs to be completely automated. EDIT: See http://stackoverflow.com/questions/425864/sed-in-vista-how-to-delete-all-symbols-between...
Hello, I have the followign bash script to update mtimes for maildir files: #!/bin/bash for i in /test/emailfile do date=$(sed -n '/Received: from/ { :a; n; /;/ {s/.*; //p;q}; b a }' "$i") newdate=$(date -d "$date" +'%Y%m%d%H%M.%S') touch -t "$newdate" "$i" done This script has always worked fine, with standard headers ...
I'm trying to search and replace a string in all files matched by grep on a linux machine. I've got some pieces of what I want to do, but I'm unsure how best to string them all together. grep -n 'foo' * will give me output in the form: [filename]:[line number]:[text] For each file returned by grep, I'd like replace "foo" with "bar" ...
I have a list of objects output from ldapsearch as follows: dn: cn=HPOTTER,ou=STUDENTS,ou=HOGWARTS,o=SCHOOL dn: cn=HGRANGER,ou=STUDENTS,ou=HOGWARTS,o=SCHOOL dn: cn=RWEASLEY,ou=STUDENTS,ou=HOGWARTS,o=SCHOOL dn: cn=DMALFOY,ou=STUDENTS,ou=HOGWARTS,o=SCHOOL dn: cn=SSNAPE,ou=FACULTY,ou=HOGWARTS,o=SCHOOL dn: cn=ADUMBLED,ou=FACULTY,ou=HOGWARTS...
I want to add a row of headers to an existing CSV file, editing in place. How can I do this? echo 'one, two, three' > testfile.csv and I want to end up with column1, column2, column3 one, two, three (nb changing the initial CSV output is out of my hands) EDIT: I originally had this as 'using sed' but any standard command w...
I have a file that contains this kind of paths: C:\bad\foo.c C:\good\foo.c C:\good\bar\foo.c C:\good\bar\[variable subdir count]\foo.c And I would like to get the following file: C:\bad\foo.c C:/good/foo.c C:/good/bar/foo.c C:/good/bar/[variable subdir count]/foo.c Note that the non matching path should not be modified. I know how...
I am writing a shell (bash) script and I'm trying to figure out an easy way to accomplish a simple task. I have some string in a variable. I don't know if this is relevant, but it can contain spaces, newlines, because actually this string is the content of a whole text file. I want to replace the last occurence of a certain substring w...
With sed, what is a one liner to print the first n characters. I am doing the following. grep -G 'defn -test.*' OctaneFullTest.clj | sed .... ...
I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script. The files have the following structure: field 1, field 2, ... field n data and, given the likelihood of having spaces in the ident...
How can I insert newlines in an html file before each table related tag using sed? ...
I had the impression sed wasn't blocking, because when I do say: iostat | sed sed processes the data as it arrives, but when I do iostat | sed | netcat Then sed blocks netcat. Am I right? ...
Hi all, I have sed related question: If I run these command from a scrip: #my.sh PWD=bla sed 's/xxx/'$PWD'/' ... $ ./my.sh xxx bla Which is fine. But, if i run: #my.sh sed 's/xxx/'$PWD'/' ... $ ./my.sh $ sed: -e expression #1, char 8: Unknown option to `s' I read in tutorials that to substitute env. variables from shell you need...
Hi, I know how to use sed with grep, but within Perl the below fails. How can one get sed to work within a Perl program? chomp (my @lineNumbers=`grep -n "textToFind" $fileToProcess | sed -n 's/^\([0-9]*\)[:].*/\1/p'`) ...
I have a string input to my program of the form: con*.cc I want this to represent the regular expression, con.*.cc. How can I do this inside a C program? Is there something like sed that I can use? ...