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.
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
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.
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.
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:
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.
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 *).
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.
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.
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.
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 ?
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.
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]
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?
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.
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.
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