Search Results

Search found 720 results on 29 pages for 'sed'.

Page 4/29 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • SED whitespace removal within a string

    - by blazeprogrammer
    I'm trying to use sed to replace whitespace within a string. For example, given the line: var test = 'Some test text here.'; I want to get: var test = 'Sometesttexthere.'; I've tried using (\x27 matches the '): sed 's|\x27\([^x27[:space:]]*\)[[:space:]]|\x27\1|g but that just gives var test = 'Sometest text here.'; Any ideas?

    Read the article

  • sed as grep + ignore # and match

    - by yael
    I have the following file example more somefile param=a b c d e f g z x w # param=a b c d e f g z x w I need to create with sed the following (should be one line if possible): Ignore # char in the beginning of line Match first the param string Second match the "a b c d e f g z x w" (like grep -w) and give exit status if success Something like .... sed "/^ *#/b; /\<param\>/" ....

    Read the article

  • sed 's/this/that/' -- ignoring g but still replace entire file

    - by lakshmipathi
    as title said, Im trying to change only the first occurrence of word.By using sed 's/this/that/' file.txt though i'm not using g option it replace entire file. How to fix this.? UPDATE: $ cat file.txt first line this this this this $ sed -e '1s/this/that/;t' file.txt first line this // ------> I want to change only this "this" to "that" :) this this this

    Read the article

  • using sed to replace whole word containing '='?

    - by rashid
    EDIT i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0 when i use sed -i -e 's/imagecolor=0/imagecolor=1/' it will change 1 and 2 line. But i only want it to replace first line. i also tried sed with \< \ and \b \b, but no luck. Could it be the '=' sign? Do we have something like -w as in grep command? Thank you.

    Read the article

  • Regular expression - skip string in quotes using sed

    - by milano
    I have string like this: "Some standard text CONST_INSIDE_QUOTES" blah blah CONST "There might be another quotes" The thing is, that i want to replace all constants in string with some text, but it mustn't be applied on constants inside text in quotes. I have this regex: sed "s/([A-Z][A-Z0-9_]*)([^a-z])/<span class=\"const\"\1<\/span\2/g" which of course works for all consts. Any ideas how to exclude its apply on quotes constants? Unfortunately sed only...

    Read the article

  • Search and replace with sed

    - by Binoy Babu
    Last week I accidently externalized all my strings of my eclipse project. I need to revert this and my only hope is sed. I tried to create scripts but failed pathetically because I'm new with sed and this would be a very complicated operation. What I need to do is this: Strings in class.java file is currently in the following format(method) Messages.getString(<key>). Example : if (new File(DataSource.DEFAULT_VS_PATH).exists()) { for (int i = 1; i <= c; i++) { if (!new File(DataSource.DEFAULT_VS_PATH + Messages.getString("VSDataSource.89") + i).exists()) { //$NON-NLS-1$ getnewvfspath = DataSource.DEFAULT_VS_PATH + Messages.getString("VSDataSource.90") + i; //$NON-NLS-1$ break; } } } The key and matching Strings are in messages.properties file in the following format. VSDataSource.92=No of rows in db = VSDataSource.93=Verifying db entry : VSDataSource.94=DB is open VSDataSource.95=DB is closed VSDataSource.96=Invalid db entry for VSDataSource.97=\ removed. So I need the java file back in this format: if (new File(DataSource.DEFAULT_VS_PATH).exists()) { for (int i = 1; i <= c; i++) { if (!new File(DataSource.DEFAULT_VS_PATH + "String 2" + i).exists()) { //$NON-NLS-1$ getnewvfspath = DataSource.DEFAULT_VS_PATH + "String 1" + i; //$NON-NLS-1$ break; } } } How can I accomplish this with sed? Or is there an easier way?

    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

  • Bash: Extract Range with Regular Expressioin (maybe sed?)

    - by sixtyfootersdude
    I have a file that is similar to this: <many lines of stuff> SUMMARY: <some lines of stuff> END OF SUMMARY I want to extract just the stuff between SUMMARY and END OF SUMMARY. I suspect I can do this with sed but I am not sure how. I know I can modify the stuff in between with this: sed "/SUMMARY/,/END OF SUMMARY/ s/replace/with/" fileName (But not sure how to just extract that stuff). I am Bash on Solaris.

    Read the article

  • sed to insert on first match only

    - by SS.
    UPDATED: Using sed, how can I insert (NOT SUBSTITUTE) a new line on only the first match of keyword for each file. Currently I have the following but this inserts for every line containing Matched Keyword and I want it to only insert the New Inserted Line for only the first match found in the file: sed -ie '/Matched Keyword/ i\New Inserted Line' *.* For example: Myfile.txt: Line 1 Line 2 Line 3 This line contains the Matched Keyword and other stuff Line 4 This line contains the Matched Keyword and other stuff Line 6 changed to: Line 1 Line 2 Line 3 New Inserted Line This line contains the Matched Keyword and other stuff Line 4 This line contains the Matched Keyword and other stuff Line 6

    Read the article

  • Sed not working inside bash script

    - by Isabelle
    Hello. I believe this may be a simple question, but I've looked everywhere and tried some workarounds, but I still haven't solved the problem. Problem description: I have to replace a character inside a file and I can do it easily using the command line: sed -e 's/pattern1/pattern2/g' full_path_to_file/file But when I use the same line inside a bash script I can't seem to be able to replace it, and I don't get an error message, just the file contents without the substitution. #!/bin/sh VAR1="patter1" VAR2="patter2" VAR3="full_path_to_file" sed -e 's/${VAR1}/${VAR2}/g' ${VAR3} Any help would be appreciated. Thank you very much for your time.

    Read the article

  • SED, using variables and in with an array

    - by S1syphus
    What I am trying to do is run the sed on multiple files in the directory Server_Upload, using variables: AB${count} Corresponds, to some variables I made that look like: echo " AB1 = 2010-10-09Three " echo " AB2 = 2009-3-09Foo " echo " AB3 = Bar " And these correspond to each line which contains a word in master.ta, that needs changing in all the text files in Server_Upload. If you get what I mean... great, I have tried to explain it the best I can, but if you are still miffed I'll give it another go as I found it really hard to convey what I mean. cd Server_Upload for fl in *.UP; do mv $fl $fl.old done count=1 saveIFS="$IFS" IFS=$'\n' array=($(<master.ta)) IFS="$saveIFS" for i in "${array[@]}" do sed "s/$i/AB${count}/g" $fl.old > $fl (( count++ )) done It runs, doesn't give me any errors, but it doesn't do what I want, so any ideas?

    Read the article

  • sed replacement does not work

    - by Robin Hood
    Hello, I have trouble using sed. I need to replace some lines in very deprecated HTML sites which consist of many files. My script does not work and I do not why. When I tried to find exact pattern with Netbeas it worked. find . -type f -name "*.htm?" -exec sed -i -r 's/ing\. Šuhajda Dušan\, Mírová 767\, 518 01 Dobruška\, \+420 737 980 333\,/REPLACEMENT/g' {} \; Where is the mistake? Is there an alternative to replace text without searching regular expression but plain text? Thanks for any respond.

    Read the article

  • sed - trying to replace first occurrence after a match

    - by wakkaluba
    I am facing a situation that drives me nuts. I am setting up an update server which uses a json file. Don't ask why or how, it sucks and is my only possibility to achieve it. I have been trying and researching for HOURS (many) because I went ballistic and wanted to crack this on my own. But I have to realize I got stuck and need help. So sorry for this chunk but I think it is somewhat important to see... The file is a one liner and repeating the following sequence with changing values (of course). "plugin_name_foo_bar": {"buildDate": "bla", "dependencies": [{"name": "bla", "optional": true, "version": "1.00"}], "developers": [{"developerId": "bla", "email": "[email protected]", "name": "Bla bla2nd"}], "excerpt": "some text {excerpt} !bla.png|thumbnail,border=1! ", "gav": "bla", "labels": ["report", "scm-related"], "name": "plugin_name_foo_bar", "previousTimestamp": "bla", "previousVersion": "1.0", "releaseTimestamp": "bla", "requiredCore": "1", "scm": "github.com", "sha1": "ynnBM2jWo25ZLDdP3ybBOnV/Pio=", "title": "bla", "url": "http://bla.org", "version": "1.0", "wiki": "https://bla.org"}, "Exclusion": {"buildDate": "bla", "dependencies": [], and the next plugin block is glued straight afterwards. What I now want to do is to search for "plugin_foo_bar": {" as this is the unique identifier for a new plugin description block. I want to replace the first sha1 value occuring afterwards. That's where I keep failing. I always grab the first,last or any occurrence in the entire file and not the block :( "title" is the unique identifier after the sha1 value. So I tried to make the .* less greedy but it ain't working out. last attempt was heading towards: sed -i 's/("name": "plugin_name_foo_bar.*sha1": ")([a-zA-Z0-9!@#\$%^&*()\[\]]*)(", "title"\)/\1blablabla\2/1' default.json to find the sha1 value of that plugin but still no joy. I hope someone knows - preferably a simpler approach - before I now continue with trial and error until I have to puke and freakout. I am working with SED on Windows, so Unix approach might help me to figure out how to achieve this in batch but please make it as one-liner if possible. Scripts are a real pain to convert. And I just need SED and no other solution with other tools like AWK. That is absolutely out of discussion. Any help is appreciated :) Cheers Jan

    Read the article

  • Modify bash variables with sed

    - by Alexander Cska
    I am trying to modify a number of environmental variables containing predefined compiler flags. To do so, I tried using a bash loop that goes over all environmental variables listed with "env". for i in $(env | grep ipo | awk 'BEGIN {FS="="} ; { print $1 } ' ) do echo $(sed -e "s/-ipo/ / ; s/-axAVX/ /" <<< $i) done This is not working since the loop variable $i contains just the name of the environmental variable stored as a character string. I tried searching a method to convert a string into a variable but things started becoming unnecessary complicated. The basic problem is how to properly supply the environmental variable itself to sed. Any ideas how to properly modify my script are welcome. Thanks, Alex

    Read the article

  • How to remove all words written in capital letters ONLY (by using sed and/or awk)

    - by Virtual_Lotos
    I am trying to delete all words written in capital letters only by using sed: sed -r "s/\b[A-Z]\w*\s*//g" < file1 > file2 But this solution capture all the words starting with capital letters and delete them (this in not the goal). Here's an example: file1 content: AAAAAAAAAAAA BBbbbbb AbAbAbAb aaaaaBBBBB AAAAAA BBBBBB A1-B1 a1-b1 A1-b1 AA AAAAA BBBBB AAAAA Abbbb AAA AAAAA AAAABB Abbbb Baaaa Aaaaa AB AAAAAA1 BBBBBBb AAAAAA 1 BBBBBB b Result should be like this (file2 content): BBbbbbb AbAbAbAb aaaaaBBBBB A1-B1 a1-b1 A1-b1 AA Abbbb AAA Abbbb Baaaa Aaaaa AB AAAAAA1 BBBBBBb AAAAAA 1 BBBBBB b Each line of at least one digit or one lowercase letter should remain intact (should not be deleted).

    Read the article

  • SED - Regular Expression over multiple lines

    - by herrherr
    Hi there, I'm stuck with this for several hours now and cycled through a wealth of different tools to get the job done. Without success. It would be fantastic, if someone could help me out with this. Here is the problem: I have a very large CSV file (400mb+) that is not formatted correctly. Right now it looks something like this: Alan Smithee ist ein Anagramm von „The [...] „Alan Smythee“, und „Adam Smithee“." ,Alan Smithee Die Aussagenlogik ist der Bereich der Logik, der sich mit [...] ihrer Teilaussagen bestimmen. ,Aussagenlogik As you can probably see the words ",Alan Smithee" and ",Aussagenlogik" should actually be on the same line as the foregoing sentence. Then it would look something like this: Alan Smithee ist ein Anagramm von „The Smitheeeee [...] „Alan Smythee“, und „Adam Smithee“.,Alan Smithee Die Aussagenlogik ist der Bereich der Logik, der sich mit [...] ihrer Teilaussagen bestimmen.,Aussagenlogik Please note that the end of the sentence can contain quotes or not. In the end they should be replaced too. Here is what I came up with so far: sed -n '1h;1!H;${;g;s/\."?.*,//g;p;}' out.csv > out1.csv This should actually get the job done of matching the expression over multiple lines. Unfortunately it doesn't :) The expression is looking for the dot at the end of the sentence and the optional quotes plus a newline character that I'm trying to match with .*. Help much appreciated. And it doesn't really matter what tool gets the job done (awk, perl, sed, tr, etc.). Thanks, Chris

    Read the article

  • Remove a line from a csv file bash, sed, bash

    - by S1syphus
    I'm looking for a way to remove lines within multiple csv files, in bash using sed, awk or anything appropriate where the file ends in 0. So there are multiple csv files, their format is: EXAMPLEfoo,60,6 EXAMPLEbar,30,10 EXAMPLElong,60,0 EXAMPLEcon,120,6 EXAMPLEdev,60,0 EXAMPLErandom,30,6 So the file will be amended to: EXAMPLEfoo,60,6 EXAMPLEbar,30,10 EXAMPLEcon,120,6 EXAMPLErandom,30,6 A problem which I can see arising is distinguishing between double digits that end in zero and 0 itself. So any ideas?

    Read the article

  • BASH: Find highest numbered filename in a directory where names start with digits (ls, sed)

    - by Jake
    I have a directory with files that look like this: 001_something.php 002_something_else.php 004_xyz.php 005_do_good_to_others.php I ultimately want to create a new, empty PHP file whose name starts with the next number in the series. LIST=`exec ls $MY_DIR | sed 's/\([0-9]\+\).*/\1/g' | tr '\n' ' '` The preceding code gives me a string like this: LIST='001 002 004 005 ' I want to grab that 005, increment by one, and then use that number to generate the new filename. How do I do that in BASH?

    Read the article

  • Convert URLs into HTML links using sed?

    - by Mike Crittenden
    I'm wondering if it's possible (recommended might be the better word) to use sed to convert URLs into HTML hyperlinks in a document. Therefore, it would look for things like: http://something.com And replace them with <a href="http://something.com">http://something.com</a> Any thoughts? Could the same also be done for email addresses?

    Read the article

  • Replacing Part of Text Using Sed

    - by neversaint
    I have the following text file Eif2ak1.aSep07 Eif2ak1.aSep07 LOC100042862.aSep07-unspliced NADH5_C.0.aSep07-unspliced LOC100042862.aSep07-unspliced NADH5_C.0.aSep07-unspliced What I want to do is to remove all the text starting from period (.) to the end. But why this command doesn't do it? sed 's/\.*//g' myfile.txt What's the right way to do it?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >