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 *).
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.
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.
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?
run_repeatedly "programX -o "./messy/path/output-$NUM.txt"" The echo inside the loop prints "...-$NUM.txt"; obviously I'm aiming to have bash substitute the iteration number so that I end up with many output files not 1.
I recently upgraded my file/media server to Fedora 11. After doing so, I can no longer copy large files to the server. The files begin to transfer, but typically after about 1gb of the file has transferred, the transfer stalls and ultimately fails with the message:
"Error writing to file: Input/output error"
I've run out of ideas as to what could cause this problem. I have tried the following:
1. Different NFS versions: NFS3 and NFS4 2. Tried copying the files to different physical drives on the server. 3. Tried copying the files from different physical drives on the client. 4. Tried different rsize and wsize block sizes when mounting the NFS share 5. Tried copying the files via a different protocol. SSH in this case. The file transfers are always successful when I use SSH.
Regardless of what I do, the result is the same. The file transfers always fail after approximately 1gb.
Some other notes.
1. Both the client and the server are running Fedora 11 kernel 2.6.29.5-191.fc11.x86_64
I am out of ideas. Has anyone else experienced something similar?
When I try to boot into Ubuntu I get this error message:t of filesystems failed.3d82d6-5dcb-494b-b2f0-fe9f157e9430Any ideas on how to fix it? I have a duel boot with XP and Ubuntu 9.10.
I have a Windows 7 partition, a fat32 partition that I use for moving data between Windows and Linux, and an Ubuntu partition. On the Ubuntu partition, I can right click on a text file and the top of the menu says "open with 'gedit'." On the fat32 partition, the same action says just "open," and the "open with" submenu doesn't include gedit.
If I right-click and choose properties on the same file, the "open with" tab shows gedit as the default file association. So that's weird... anyone else seen anything like this?
have been using karmic studio for around a month now, and have been recently experiencing some boot issues where 1 of 3 things are happening;1) failed to mount filesystem, where maintenance shell is initiated2) insert boot media and press any key to continue3) i get to log in and everything looks ok until i click the application menu, where nothing appears and all logos (shutdown/log off etc) appear as red crosses
I have a dual boot with Arch linux that share a /home partition. Whenever ubuntu starts tho it tries to do a check on the /home partition and fails.... it gets an error saying unable to check then drops into a shell. I have to run it in recovery mode frequently then start it up and it usually works, but i have to type startx after logging into a shell before that
I installed the server and client from the repositories. I got version 1.8:
[Code].....
Got everything running, apparently normally, but then I noticed the GUI Installation tab. This helped me optimize the php.ini file so the pretty front end could be used. I got the step 7 where it says
Each line of the file I am sorting is in the following format:
<url> <month> <day>
For example:
[URL]
I wrote the following to sort:
Code:
#!/usr/bin/perl $in = shift; chomp($in);
[code]....
The script worked fine for my small testing files, but failed in my input file. The input file is 18MB and containing more than 300,000 lines. The output will contains some lines like that:
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]
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 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.