Search Results

Search found 490 results on 20 pages for 'awk'.

Page 8/20 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How to remove lowercase sentence fragments from text?

    - by Aaron
    Hello: I'm tyring to remove lowercase sentence fragments from standard text files using regular expresions or a simple Perl oneliner. These are commonly referred to as speech or attribution tags, for example - he said, she said, etc. This example shows before and after using manual deletion: Original: "Ah, that's perfectly true!" exclaimed Alyosha. "Oh, do leave off playing the fool! Some idiot comes in, and you put us to shame!" cried the girl by the window, suddenly turning to her father with a disdainful and contemptuous air. "Wait a little, Varvara!" cried her father, speaking peremptorily but looking at them quite approvingly. "That's her character," he said, addressing Alyosha again. "Where have you been?" he asked him. "I think," he said, "I've forgotten something... my handkerchief, I think.... Well, even if I've not forgotten anything, let me stay a little." He sat down. Father stood over him. "You sit down, too," said he. All lower case sentence fragments manually removed: "Ah, that's perfectly true!" "Oh, do leave off playing the fool! Some idiot comes in, and you put us to shame!" "Wait a little, Varvara!" "That's her character," "Where have you been?" "I think," "I've forgotten something... my handkerchief, I think.... Well, even if I've not forgotten anything, let me stay a little." He sat down. Father stood over him. "You sit down, too," I've changed straight quotes " to balanced and tried: ” (...)+[.] Of course, this removes some fragments but deletes some text in balanced quotes and text starting with uppercase letters. [^A-Z] didn't work in the above expression. I realize that it may be impossible to achieve 100% accuracy but any useful expression, perl, or python script would be deeply appreciated. Cheers, Aaron

    Read the article

  • matching files with regular expressions

    - by Javier
    Dear all, I have an input file with a list of movies (Note that there might be some repeated entries): American_beauty__1h56mn38s_ As_Good_As_It_Gets As_Good_As_It_Gets _DivX-ITA__Casablanca_M_CURTIZ_1942_Bogart-bergman_ Capote_EN_DVDRiP_XViD-GeT-AW _DivX-ITA__Casablanca_M_CURTIZ_1942_Bogart-bergman_ I would to find the corresponding match (line number) from another reference file for each of the entries in the first file: American beauty.(1h56mn38s) As Good As It Gets Capote.EN.DVDRiP.XViD-GeT-AW [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) Quills (2000)(7.4) The desired output would be something like (Reference Movie + Line number from the Reference File): American beauty.(1h56mn38s) 1 As Good As It Gets 2 As Good As It Gets 2 [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) 4 Capote.EN.DVDRiP.XViD-GeT-AW 3 [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) 4 Basically, the difference between the entries in both files is that some characters such as: blank spaces, parenthesis, points, etc. have been replaced by underscores. Does anybody could shed some light on it? Best wishes, Javier

    Read the article

  • replace a text string

    - by shantanuo
    I want to replace the date found at the end of the "datadir" line with the current date. For e.g. my my.cnf file looks like this... # head /etc/my.cnf [mysqld] #mount -t tmpfs -o size=102m tmpfs /mnt #datadir=/mnt read-only datadir=/mysqlApr5 #datadir=/mysqlApr2 #datadir=/mysqlMar16 #datadir=/mysqlFeb25a Most of the lines are commented. I need to find the datadir line that is not commented and then replace the /mysqlApr4 with /mysqlApr20 datadir=/mysqlApr20 If it is possible I will like to comment the older datadir path. #datadir=/mysqlApr5 I can output the current date as: date '+%b%d' But I want to concat it with the word "/mysql" and replace or comment the current datadir line.

    Read the article

  • replace the line to add some text

    - by shantanuo
    The MySQL dump backup file has the following line... # head -40 backup20-Apr-2010-07-32.sql | grep 'CHANGE MASTER TO ' -- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000068', MASTER_LOG_POS=176357756; a) I need to complete the statement with the parameters like Master host, user and password. b) I do also need to remove the comment "--" The line should look something like this... CHANGE MASTER TO MASTER_HOST='111.222.333.444', MASTER_USER='slave_user', MASTER_PASSWORD='slave_user', MASTER_LOG_FILE='mysql-bin.000068', MASTER_LOG_POS=176357756;

    Read the article

  • How do I get Git's latest stable release version number?

    - by MattDiPasquale
    I'm writing a git-install.sh script: http://gist.github.com/419201 To get Git's latest stable release version number, I do: LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p') 2 Questions: Refactor my code: Is there a better way programmatically to do this? This works now, but it's brittle: if the web page at http://git-scm.com/ changes, the line above may stop working. PHP has a reliable URL for getting the latest release version: http://stackoverflow.com/questions/288206/is-there-a-site-which-simply-outputs-the-latest-stable-version-numbers-of-php-and Is there something like this for Git? This comes close: http://www.kernel.org/pub/software/scm/git/

    Read the article

  • Change Number Format

    - by gsembilan
    I have a lot lines contains XXXXXXXXX number format. I want change number XXXXXXXXX to XX.XXX.XXX.X XXXXXXXXX = 9 digit random number Anyone can help me? Thanks in advance

    Read the article

  • shell script filter du and find by a string inside a file in a subfolder

    - by Jason
    I have the following command that I run on cygwin: find /cygdrive/d/tmp/* -maxdepth 0 -mtime -150 -type d | xargs du --max-depth=0 > foldersizesreport.csv I intended to do the following with this command: for each folder under /d/tmp/ that was modified in last 150 days, check its total size including files within it and report it to file foldersizesreport.csv however that is now not good enough for me, as it turns out inside each /d/tmp/subfolder1/somefile.properties /d/tmp/subfolder2/somefile.properties /d/tmp/subfolder3/somefile.properties /d/tmp/subfolder4/somefile.properties so as you see inside each subfolderX there is a file named somefile.properties inside it there is a property SOMEPROPKEY=3808612800100 (among other properties) this is the time in millisecond, i need to change the command so that instead of -mtime -150 it will include in the whole calculation only subfolderX that has a file inside them somefile.properties where the SOMEPROPKEY=3808612800100 is the time in millisecond in future, if the value SOMEPROPKEY=23948948 is in past then dont at all include the folder in the foldersizesreport.csv because its not relevant to me. so the result report should be looking like: /d/tmp/,subfolder1,<itssizein KB> /d/tmp/,subfolder2,<itssizein KB> and if subfolder3 had a SOMEPROPKEY=34243234 (time in ms in past) then it would not be in that csv file. so basically I'm looking for: find /cygdrive/d/tmp/* -maxdepth 0 -mtime -150 -type d | <only subfolders that have in them property in file SOMEPROPKEY=28374874827 - time in ms in future and not in past | xargs du --max-depth=0 > foldersizesreport.csv

    Read the article

  • How do I grep for entire, possibly wrapped, lines of code?

    - by NXT
    When searching code for strings, I constantly run into the problem that I get meaningless, context-less results. For example, if a function call is split across 3 lines, and I search for the name of a parameter, I get the parameter on a line by itself and not the name of the function. For example, in a file containing ... someFunctionCall ("test", MY_CONSTANT, (some *really) - long / expression); grepping for MY_CONSTANT would return a line that looked like this: MY_CONSTANT, Likewise, in a comment block: ///////////////////////////////////////// // FIXMESOON, do..while is the wrong choice here, because // it makes the wrong thing happen ///////////////////////////////////////// Grepping for FIXMESOON gives the very frustrating answer: // FIXMESOON, do..while is the wrong choice here, because When there are thousands of hits, single line results are a little meaningless. What I would like to do is have grep be aware of the start and stop points of source code lines, something as simple as having it consider ";" as the line separator would be a good start. Bonus points if you can make it return the entire comment block if the hit is inside a comment. I know you can't do this with grep alone. I also am aware of the option to have grep return a certain number of lines of content. Any suggestions on how to accomplish under Linux? FYI my preferred languages are C and Perl. I'm sure I could write something, but I know that somebody must have already done this. Thanks!

    Read the article

  • [sed] Multiline trimming

    - by wwrob
    I have a html file that I want to trim. I want to remove a section from the beginning all the way to a given string, and from another string to the end. How do I do that, preferably using sed?

    Read the article

  • How can I quickly sum all numbers in a file?

    - by Mark Roberts
    I have a file which contains several thousand numbers, each on it's own line: 34 42 11 6 2 99 ... I'm looking to write a script which will print the sum of all numbers in the file. I've got a solution, but it's not very efficient. (It takes several minutes to run.) I'm looking for a more efficient solution. Any suggestions?

    Read the article

  • comparing two files and merge the data

    - by Ganz Ricanz
    I have the below files, total.txt order1,5,item1 order2,6,item2 order3,7,item3 order4,6,item4 order8,9,item8 changed.txt order3,8,item3 order8,12,item8 total.txt is total order data and changed.txt is recently changed data. I want to merge the recent change with total, i want the output as , Output.txt order1,5,item1 order2,6,item2 order3,8,item3 order4,6,item4 order8,12,item8 Note : 2nd column of (3rd & 5th) row of the total.txt is updated with changed.txt file i have used the below nawk to compare the first coulmn, but not able to print it to the output file. Please help on complete the below command nawk -F"," 'NR==FNR {a[$1]=$2;next} ($1 in a) "print??"' total.txt changed.txt

    Read the article

  • bash split text into limited character buckets (array member)

    - by soField
    i have text such as http://pastebin.com/H8zTbG54 we can say this text is set of rules splitted by "OR" at the end of lines i need to put set of lines(rules) into buckets (bash array members) but i have character limit for each array member which is 1024 so each array member should contain set of rules but character count for each array member can not exceed 1024 can anybody help me to do that solaris 10

    Read the article

  • linux ps aux command

    - by lakshmipathi
    How obtain the running process with absolute path name from ps command 13598 ? Ssl 0:00 /opt/something --run-id 2 -n /home/laks/f1 -l l.log I need the output as - /opt/something --run-id 2 -n /home/laks/f1 -l l.log

    Read the article

  • Grep in XML file

    - by nishant
    I have to find some patters from a XML file, but i am unable to do it. <field> <uniqueid>account </uniqueod> <tableid>afs</tableid> </field> <field> <uniqueid>address</uniqueod> <tableid>afs</tableid> </field> what i have to do is to search the entries between these two fields and redirect them to a file.txt.and output should be such that uniqueid tableid uniqueid tableid i.e. for each uniqueid tableid should be printed along with it. The entries can be different or same. Guys help me out...

    Read the article

  • How can I change spaces to underscores and lowercase everything?

    - by benjamin button
    I have a text file which contains: Cycle code Cycle month Cycle year Event type ID Event ID Network start time I want to change this text so that when ever there is a space, I want to replace it with a _. And after that, I want the characters to lower case letter like below: cycle_code cycle_month cycle_year event_type_id event_id network_start_time How could I accomplish this?

    Read the article

  • Unix: replace every odd | with \left| and every even | with \right|

    - by HH
    An enormous equation. You need to add \left| on the left side of corresponding |. The corresponding | you need to replace with \right|. Equation \begin{equation} | \Delta w_{0} | = \frac{|w_{0}|}{2} \left( |\frac{\Delta g}{g}|+|\frac{\Delta (\Delta r)}{\Delta r}| + |\frac{\Delta r}{r}| +|\frac{\Delta L}{L}| \right) \end{equation}

    Read the article

  • how to replace strings in file based on values from another file? (example inside)

    - by thaold
    Hi, how to replace strings in file, based on values from another file. Example, 2 files - input, output input: 12345 1 output: (1,'a lot of text', 'some other info',0,null, 12345), (2,'a lot of text', 'some other info',0,null, 12345), (3,'a lot of text', 'some other info',0,null, 12345), (4,'a lot of text', 'some other info',0,null, 12345), (5,'a lot of text', 'some other info',0,null, 12345); Needs to be done: read values from file 'input', and replace all '12345' with '1' in file 'output'. Thanks for help in advance

    Read the article

  • rule based file parsing

    - by user359490
    I need to parse a file line by line on given rules. Here is a requirement. file can have multiple lines with different data.. 01200344545143554145556524341232131 1120034454514355414555652434123213101200344545143554145556524341232131 2120034454514 and rules can be like this. if byte[0,1] == "0" then extract this line to /tmp/record0.dat if byte[0,1] == "1" then extract this line to /tmp/record1.dat if byte[0,1] == "2" then extract this line to /tmp/record2.dat I am looking for any language which can do this in a fast manner with a very long file size like 2 GB. Appreciate all the help in advance. Thanks

    Read the article

  • Using placeholders/variables in a sed command

    - by jesse_galley
    I want to store a specific part of a matched result as a variable to be used for replacement later. I would like to keep this in a one liner instead of finding the variable I need before hand. when configuring apache, and use mod_rewrite, you can specificy specific parts of patterns to be used as variables,like this: RewriteRule ^www.example.com/page/(.*)$ http://www.example.com/page.php?page=$1 [R=301,L] the part of the pattern match that's contained inside the parenthesis is stored as $1 for use later. So if the url was www.example.com/page/home, it would be replaced with www.example.com/page.php?page=home. So the "home" part of the match was saved in $1 because it was the part of the pattern inside the parenthesis. I want something like this functionality with a sed command, I need to automatically replace many strings in a SQL dump file, to add drop table if exist commands before each create table, but I need to know the table name to do this, so if the dump file contains something like: ... CREATE TABLE `orders` ... I need to run something like: cat dump.sql | sed "s/CREATE TABLE `(.*)`/DROP TABLE IF EXISTS $1\N CREATE TABLE `$1`/g" to get the result of: ... DROP TABLE IF EXISTS `orders` CREATE TABLE `orders` ... I'm using the mod_rewrite syntax in the sed command as a logical example of what I'm trying to do. Any suggestions?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >