Programming :: Substitute Every Occurrence Of "( S" To "(S" In File

Mar 11, 2011

I want to substitute every occurance of "( S" to "(S" in my file (the quotes aren't included in my file. Its just there to specify what my pattern is)

This is my attempt to do it and the error message I get.

Code:
denish@ubuntu:~/Desktop/tgrep files$ sed 's/^( (S$/(S/g' test > test2
sed: -e expression #1, char 16: Unmatched ( or (

The "( )" has a different purpose in sed. So how exactly do I specify a ( in sed as a pattern and not as the special function?

View 7 Replies


ADVERTISEMENT

Programming :: Replace 2nd Occurrence Of A String In A File - Sed Or Awk?

Apr 5, 2010

I know how to replace a particular instance (say 3rd one) of a word in a line using sed based on the sed one-liners. However I would like to replace a particular instance of a word in the entire file.

For example, here is a file:

Code:
John
Betty
Jack
Ron
Jack
Paul

So now I would like to replace the second instance of Jack (in red color) with "Rob" (for example). Not quite sure how to do that? I tried couple of things from here but they did not work.

View 10 Replies View Related

Programming :: Substitute Text From Master File?

Mar 29, 2010

i have a PHP program, it encompasses about 200 scripts. Years ago, it was rewritten by another programmer to be multi-lingual, but the multi-lingual attraction of it never took off. Now that I am the only maintainer, trying to reuse what I have for code is quite difficult. If I look at one script, I see items like

_HEADER_TEXT_ERROR_4
_TABLE_ROW_SIZED_FORMAT
_ERROR_SELECT_RADIO_MAIN

All of these (and many more) are found in a "main.php" file that sort of go like this:

DEFINE _HEADER_TEXT_ERROR_4 "You Entered a Bad Value";
DEFINE _TABLE_ROW_SIZED_FORMAT "Last Name";
DEFINE _ERROR_SELECT_RADIO_MAIN "Make Your Selections";

What I would like to do is have something that says FOR all files in this directory, when you find something that starts with _, find that value in main.php and substitue what is inside the quotes for that value. Sort of unwriting all this multi-lingual stuff. I can format how I would do it if it was all stored in MySQL, but doing it from bash has me perplexed.

View 11 Replies View Related

Programming :: Awk Command - Search Pattern To Look For Last Occurrence

May 11, 2011

Any solution using awk/sed/regexp or other standard linux utility (this is for a mix of RH versions)? I am dealing with some very large application log files. I want to see everything that has been written to the log since the last application restart.

For an example take a log file like this:
Code:
# cat test.log
1 msg
2 msg
3 restart 1
4 msg
5 restart 2
6 msg

The following command is close to what I want:
Code:
# awk '/restart/,G' test.log
3 restart 1
4 msg
5 restart 2
6 msg

But the awk command grabs the first restart not the last. If it was working the way I wanted I would see something like this:
Code:
# awk '/restart/,G' test.log
5 restart 2
6 msg

So, I need something in that search pattern that says look for the last occurrence. I know how to do this with a pipe line - I could reverse the file and then do a similar awk and reverse back, or I could find the number associated with the last restart and then use that in the awk search. But these just take too long because the file is too big.

View 14 Replies View Related

Programming :: Count The Number Of Occurrence Characters In A String ?

Jan 26, 2011

How do I count the number of occurrence characters in a string in an efficeint way ?

How do I reverse the words in a string with out using temp variables if possible . (if not possible use temp variables ?

Why do I specify dependedcies for header files in the Makefile ?

View 2 Replies View Related

Programming :: Add Time Of Occurrence For Mouse Event In Xinput?

Jan 24, 2011

i need to have the time of occurence for mouse event in xinput,right now i run

Code:
xinput test <device_id> >log.txt
(for finding device_id using xinput list)

[code]...

View 4 Replies View Related

Programming :: Replace Occurrence Of A String In Many Files In One Command?

Oct 30, 2010

I used a command Code:

grep -r err_sys ./
its output is
Code:
./tcpclitime.c:err_sys("socket error");
./tcpclitime.c:err_sys("connect error");
./tcpclitime.c:err_sys("write error");
./tcpclitime.c:err_sys("shutdown error");
./tcpclitime.c:err_sys("read error, n = %d", n);
[Code].....

Is it possible some how to replace all the occurrences of word err_sys by printf.

View 1 Replies View Related

General :: Replacing Word Occurrence With An Increasing Number In A File Using Bash?

Aug 2, 2010

I have a file in the form below, and wish to replace each start line with an increasing number. So instead of:

Code:
start
content content
start
content content
start

[Code]....

After several searches and a bit of messing around, it's clear I'm missing something, so was wondering if anyone could offer any insight?

View 17 Replies View Related

Programming :: Sed Substitute Everything Until Character?

Mar 30, 2010

I have the following file:

Code:

1 line
...
49 test test=AA:AA:AA:AA:AA=0

I need to substitute on the line number 49, all text until =. I have used the following, but with no actual result.

sed -re '49s/^.+=//' file
and
sed -e '49s/.*[=]//' file

View 5 Replies View Related

Programming :: Substitute Text In Many Files?

Mar 11, 2010

I have this PHP Program I have been hobbying for years. Started in old PHP3 early PHP4. So with the newer PHP, things are starting to break! I have this string:

session_is_registered('UserID')

And I need to convert to this:

isset($_SESSION['UserID'])

in more than 200 scripts in my directory. I have been toying with perl (in a copy of the dir of course in case I really screw things over, lol) but am not gettig too far. The new code needs to swap ( ) for [ ] and i'm just all hung up! I am getting lost in Perl, I have this, but it does not substitute so I am missing something:

perl -i.bak -pe "s/session_is_registered('UserID')/isset(\$_SESSION['UserID'])/g" *.php

View 7 Replies View Related

Programming :: Substitute 2 Character Country Abbreviations To 3?

Dec 20, 2010

I have a list of 2 character country abbreviations used in the Maxmind GeoCountry database that I need to convert to the standard 3 character country abbreviation ISO 3166-11 format. I could have a long list of sed substitute statements for each country.

Code:

sed "s/US/USA/g" <file>

Is their a more elegant way to do this? Maybe an array of some sort? This substitution will be used in a bash script.

View 4 Replies View Related

General :: Substitute In A File When Sed And Awk Both Fail ?

Jun 5, 2011

I have tried making this substitution using both of

Code:

Sed operates with no comment but does nothing. awk objects to the variables content because they include the occasional non-breaking-space. The presence of these is essential so that bash will properly distribute the content of each line to an array.

The content of "orc" and "orch" is as follows (the non-breaking-spaces show as *).

Code:

View 2 Replies View Related

Programming :: Substitute Few Words + Change All The Lines Starting With A Specific Word + Put Blank?

Jan 17, 2009

I have an old-address-list file which is having around 1500 entries. I need to convert this addresses in to a specific format.

The old-address-list file>
# cat old-address-list-file
dn: CN=Muhammad Hadhi K.M,OU=IT Dept,OU=Example Company H.O,DC=example,DC=com
cn: Muhammad Hadhi K.M

[code]....

View 6 Replies View Related

General :: Counting The Occurrence Of A Word In A Collection Of Files?

Jun 16, 2010

I am trying to find the word count of a specific word in a collection of documents, in Linux.

I have tried with grep and ack-grep in combination with wc but I can't seem to come up with a valid combination of pipes :)

View 1 Replies View Related

General :: Substitute In A File What It Comes With "(" Character To "?

Apr 21, 2010

i want to substitute in a file what it comes with "(" character to "('". i have tried to do it with gsub but it doesn`t go well with regular expression.

View 4 Replies View Related

Ubuntu :: Basic Graphic Actions Taking Long Occurrence Time

Jul 8, 2010

It takes an exceptionally long time for basic graphic actions to occur like switching tabs in Firefox, redrawing windows that have been (un)maximized/minimized, and switching between windows. My video card is not a bad one, a GeForce 9500 GT and Windows handles it just fine. I'm using the current NVIDIA drivers 265.35. It seems like if I can't get some better response time I'll be using Windows much more.

View 3 Replies View Related

Ubuntu Servers :: Looking For A IIS Substitute?

Jan 31, 2011

I am setting up an ubuntu server, and i was wondering if there was a program that i could apt-get that would manage my Domain names and create directories and FTP and all that good stuff like IIS does in windows. While i am fully capable of editing the files and working the server through the terminal, noone else in my office is and if we are to switch to a linux server they will need to be able to work it.

View 9 Replies View Related

Software :: Package Is Substitute Of The PHP-GD?

Aug 24, 2010

I would like to install GD package on my ubuntu , but as my ubuntu is too old that many library is required to upgrade when install GD , is there other package is substitute of the PHP-GD ?

View 2 Replies View Related

General :: Substitute Pattern With Another Patter In Vi

Apr 24, 2009

I have the large file (textfile) there are word:

code-007100
...
code-007199

How to substitute those all words, so it will change all instances to:

code-007200
...
code-007299

View 5 Replies View Related

Ubuntu :: Substitute For Intrepid Repos?

Jan 5, 2011

Is there a substitute for Intrepid repos? I'm not able to access a few servers and don't want to upgrade the OS on this box.

Code:

View 4 Replies View Related

Ubuntu :: 11.04 - Substitute For CPU Scaling Applet?

Apr 29, 2011

Since the new Unity in Ubuntu 11.04 doesn't work with applets, like GNOME, I've lost an useful applet to choose the operating clock of my CPU as well as power profiles (Performance, Conservative, On Demand etc.).

I've looked into Ubuntu Software Center but couldn't find anything similar.

View 9 Replies View Related

Red Hat / Fedora :: What Is The Substitute For RHEL Repository

Feb 21, 2011

What is the substitute for RHEL repository? I know that we can use cent-OS/ fedora repository, but can someone please tell me what exactly is required in the yum.repo file. My computer details are as mentioned.

$uname -a
Linux example.com 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux[/B]

View 2 Replies View Related

General :: SED - Substitute A Word Only In A Certain Line

Feb 2, 2010

I tried to use the command:

sed -i ''$line_number',/port/s/port/portMARKED/' file

to substitute the word "port" by the word "portMARKED" at the specific line that is saved in "line_number". The substitution happens, but it is copying my line twice... and I have no idea why... I need to make a single substitution of one word for another at a certain line in my text file. Would somebody know how I could do that?

View 3 Replies View Related

General :: Substitute Variable In Bash

Mar 21, 2011

Assume that i a having the following three lines in an executable file

#/bin/bash
a=Tue
Tue=1

When i give echo $a the value should be 1, how to do this.

View 8 Replies View Related

Fedora :: What Is The Substitute Of Windows Movie Maker?

Apr 4, 2010

what is the substitute of windows movie maker in linux?

View 7 Replies View Related

Ubuntu :: Substitute For Internet Download Manager

Jan 29, 2010

I have gone through many threads but most of them have been dead for many time and I think there would have been a few advances in the Ubuntu software domain, so maybe a new downloader is up which manages downloads in a better way.Well, those who have used Internet Download Manager know that it is one of the best ones offered for Windows. It has many useful functions available in one single domain.

- It integrates to all browsers damn well, like charm.
- It can manage rapidshare, megaupload, hotfile and similar file hosting services very smoothly.
- It is a multi-threaded downloader which means that before starting to download file it breaks it up in many small pieces, and then downloads all fragments side by side, making the download very very fast, even on slower connections.
- It can also do very well with the websites which do not permit multithreaded downloading from their servers.
- It can take on video downloads from any page on the web which has a streaming video.
- It is very stable (if bought legitimately, which is not true in most cases ). But quite stable in even when not registered or cracked.
- Above all, it has a smart gui interface which provides interactive operations on downloaded files.

I have used many downloaders for Ubuntu and there has been some problem with each one. Some have a nice CLI structure but not GUI. Some of them are not multi-threaded. Some are multithreaded but do not allow pausing and continuing downloads (which actually does not satisfy the very definition of download managers). I haven't seen a single download manager which is GUI, multithreaded and well integrated to browsers all at the same time.What I want to know is, do my friends here at Ubuntu galaxy want to point out a real shiny star here which would make me forget the damn propriety software? Or if such a downloader hasn't been built yet, why not let's build one... Shouldn't be too hard especially if we have a model example (IDM 5.18 for Windows) in front of us... Well the algorithm must be simple, get address, verify the existence of file, break apart into several pieces and start downloading. I don't know how to implement this algorithm yet, but I am a quick learner and if a few expert programmers join me, we can do something that would remove one complain for most Ubuntu users.

View 4 Replies View Related

Ubuntu :: Software Substitute For The Microsoft Expressions?

Jan 14, 2011

Is there any software substitute for the Microsoft Expressions ? Recommendations ?

View 3 Replies View Related

Ubuntu :: Substitute For Inhibit-applet In Gnome3?

May 29, 2011

I've been fiddling with gnome3 quite a bit, several different variants, and something I've yet to find a solution for is a way to "inhibit" the screensaver and/or sleep features if watching a movie or such.In gnome2 I'd always just add 'inhibit-applet' to the panel, but I've so far found no substitute in gnome3.

View 1 Replies View Related

Applications :: Octave Good Substitute For Matlab?

Jan 12, 2010

Has anybody used both of these programs? How do they compare? Is Octave a good substitute for Matlab? How similar are the programing languages?

View 4 Replies View Related

Ubuntu Installation :: Asus EPU-Six Engine Substitute - How To Slow Down Cpu

Feb 8, 2010

Does anyone know any software or tricks how slow down cpu. The aplet on top panel whose control cpu freq allow set only 2Ghz. On windows to EPU-Six i can for example set 1,8Ghz and automaticly vcore drop to 0,967V. On ubuntu the lower value is 2Ghz and 1,1V. I have Asus P5Q PRO on P45 chipset and Core 2 Duo E8400 on Ubuntu 9.10

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved