General :: Replacing Awk With Perl?
Jul 16, 2010
I want the output of this file to be in a column, not next to each ohter. I tired putting a a newline escape character in a few places, but it breaks the script. It is easy in awk, just ls -ltr | awk '{print $8 }'
casper@casper-laptop:~$ pwd
/home/casper
casper@casper-laptop:~$ ls -ltr > /tmp/outfile
casper@casper-laptop:~$ cat -n /tmp/moreawkreplace
1#!/usr/bin/perl
[Code].....
View 1 Replies
ADVERTISEMENT
Dec 17, 2010
I have a small problem with Perl and Apache.
If I use "#!/usr/bin/perl" in the beginning of a perl script the script won't work if the script is at all complicated. Simple scripts like "Hello World" works.
But if I use "#!/usr/bin/perl -w" in the beginning all scripts work?
If I don't use the -w this is whats in the logs:
(2)No such file or directory: exec of '/home/test.net/html/cgi-bin/uh/meny.pl' failed
Premature end of script headers: meny.pl
When I use the -w in the script the error-log shows me this.
meny.pl: Name "main::http_path_cgi" used only once: possible typo at /home/test.net/html/cgi-bin/uh/meny.pl line 24.
View 1 Replies
View Related
Jan 17, 2011
Possible Duplicate: replacing dot in string, but leaving last one replace the "." [dots], but leave the last one: e.g.: .txt [there could be random number of dots in the string, even zero, i just need the last one]
$ echo 'someth.ing.something.txt' | SOMEMAGIC
someth-ing-something.txt
$
View 1 Replies
View Related
Jan 30, 2010
Is there any working commandline alternative to # find /some/dir -group xxx -user yyy | chown xxxxx:yyyyyThe main purpose is to replace ownership and goup of certain files in subdirectories. Or nevertheless I need to write shell script for that simple operation ?
View 5 Replies
View Related
Jul 26, 2010
how to replace following text in the file name.cfg ?I need to replace
name:=inet.hr=>1|inet.hr=>1
with
name:=none
I am using
sed -i 's/name:=inet.hr=>1|inet.hr=>1/name:=none/g' name.cfg
View 4 Replies
View Related
Mar 19, 2011
assume that i am having the following line in a file called file1. triumph and disaster must be treated same. I want to replace this line with. follow excellence success will chase you. is it possible to do this using sed. if possible kindly post me the code.
View 6 Replies
View Related
Jan 5, 2011
I have a line like
port = 2566
I want to replace it as
port = 8080
how to do this in shell script. when i tried to do this with sed
sed -i 's/port=.*/port='$3'/' /root/$2
it is not recognizing spaces , it works only if line is port=2566 .
View 6 Replies
View Related
Jun 21, 2011
I need to replace a value in a file. For example the content of data.txt file is:
1 1 23
2 1 42
3 2 52
4 2 62
5 1 77
6 1 88
7 2 99
8 1 100
Could I substitute 2 in second column with 3 using awk and or sed or other command so that the data will be change as follow?
1 1 23
2 1 42
3 3 52
4 3 62
5 1 77
6 1 88
7 3 99
8 1 100
View 3 Replies
View Related
Apr 25, 2010
I have just re transcoded a bunch of avi's. to tell the new ones from the old ones I put '[xvid]' at the end of all the new avi's. but now I have deleated the old avi's I want to remove the [xvid] part of the file name. This is what I have so far
Code:
#!/bin/bash
for name in *.avi
do
newname=`echo "$name" | tr -d [xvid]`
[Code]...
View 10 Replies
View Related
Jan 28, 2011
I've got a 3 year old self-assembled system running Ubuntu 9.04, with an AMD Phenom 9850 quadcore with 4G ram on and M3A78-EMH-HDMI motherboard. I'm not really a hardware person, but the assembly was pretty smooth. A year ago (while running Ubuntu 8.04) I started getting messages that my HD was about to die (a 500G Western Digital). I ran out and bought two new HDs, a 1T WD Caviar black onto which I copied everything from the dying drive, and a 500G WD Caviar green onto which I installed Ubuntu 9.04. Everything went fine, except that I couldn't seem to get the system to boot if I removed the dying drive. So I just left it in. I've been getting "About to die" messages for the last year, but I had all the data on the backup 1T drive, and the system was actually running from the new 500G drive, so I didn't worry about it.
Last week the dying drive finally actually died, and the system failed to reboot on the next try, the error message was: Secondary Master Hard Disk Error No IDE Master H.D.D. Detected! Press F1 to ResumeNothing happened after hitting F1. There are 6 SATA ports, 4 red ones (1-4) and 2 black ones (5-6). Sadly, I failed to note which ports the drives were plugged into before I started tinkering. I seem to be able to replicate this error whenever the 500G drive with the master boot record is in a higher numbered port than the 1 T drive. If I reverse that so the 500G is on a lower port number, and if I make sure that the 500G drive has a higher boot priority in BIOS, then I get no error messages at all, but after the POST sequence is finished all I get is a blinking cursor at the top of the screen that doesn't respond to the keyboard (never even getting to GRUB). I can Ctrl-Alt-Delete to reboot, but nothing else has any effect.......
View 14 Replies
View Related
Oct 11, 2010
I have a String like "A.words=Ajay,Anil" in file A.And it contains a lot of other information also. I wanted to replace "Ajay,Anil" with "Vijay,Vinay" with sed command with using existing file only(not using another file)
View 9 Replies
View Related
Mar 11, 2011
I'm executing the below bash script, but when the m variable doesn't get any value it becomes empty. I don't want that.
Code:
for i in "$@"
do
m=$(grep TOTAL_MAPS $i | awk '{ print $2}');
totalmaps+="<string>"$m"</string>"
[Code]....
View 6 Replies
View Related
Mar 15, 2011
I want to save some money in the office and instead of paying windows I want to use Ubuntu.
I know of way to add ubuntu to a windows server and I have recently installed a ClearOs box as a domain controller out of the box to add xp machines to. can anyone tell me how I would get an Ubuntu desktop machine to authticate for shares and login with my clearos box which is based on Centos.
If I can get this done, I can loose the windows machine and use zimbra as well instead of exchange.
View 1 Replies
View Related
Aug 11, 2010
I am new here and want to lern CentOS. Current I have installed CentOS 5.5 x64 and Perl 5.8.8. Now i have install Perl 5.12.1 which located to /usr/local/bin/perl. But how I can move it to /usr/bin/perl so root based on Perl 5.12.1?
View 7 Replies
View Related
Dec 24, 2010
I replaced one old RAM module with two newer, bigger ones, but now, the sound doesn't seem to work anymore. Already ran alsaconf andOutput of lspci for the audio device:
00:07.0 Audio device: nVidia Corporation MCP67 High Definition Audio (rev a1)
Subsystem: Giga-byte Technology Device a002
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR-
[code]....
View 1 Replies
View Related
Mar 20, 2011
I have installed latest Sun JDk. But when I do: java -version I still got OpenJDK version. So I completely removed OpenJDK. But now when I do:
java -version I get even older GNU java 1.5 something libgcj. So I completely removed that too but it was asking to remove bunch of dependent apps like OpenOffice.org Writer etc. Even though I need the writer, I let it go because I do not want ever to see the face of any GNU java on my linux. So everything related to GNU java is removed. Luckily I am able to start Eclipse and it works fine and start normally (apparently using the installed Sun JDK which is what I want). But now when I run
java -version I get bash: /usr/bin/java: No such file or directory Now what I need to do so that when I open any terminal window and enter java -version I should get Sun JDK version? Sun JDK is installed in /usr/java/jdk1.6.021. I also have symlinks: /usr/java/latest and /usr/java/defaults pointing to sun jdk.
As suggested in the answer, I tried the alternatives command but it did nothing. I type the --display, nothing is shown, and --config does nothing.
View 1 Replies
View Related
Dec 12, 2009
I have a 5 disk raid 5 array that is composed of SATA A:0,1; SATA B: 0,1, and SATA C:0, and one of the disks (SATA A:0) recently went bad on me. I have an ICP raid controller that is about 5 years old. I replaced SATA A:0. After rebooting, I went into the controller and verified that it saw the disk in the hard-disk info section...there I noticed that in the "status" section, that the SATA C:0, SATA B:1 disks were listed as being "in array", the SATA A disks were blank, and the SATA B:0 disk was listed as "fragment". When I go into the "repair array" section, the controller tells me that there are no arrays that are in failure, error, or need to be rebuilt.
This puzzles me, as I thought the controller would know that the array needs to be rebuilt after replacing the disk and I don't see a way to initiate a rebuild. If I just let the server boot after replacing the disk, then I get back that there are the correct number of disks in the raid 5 and that it is ready, however, the screen then goes blank and I get a blinking cursor and the system seems to hang. There are no activity lights on any of the drives associated with the raid 5, which makes me think that the system is not rebuilding the array at this point.
View 3 Replies
View Related
Jun 21, 2009
I have a text file with content that look like this..
Code:
1,3927,"AIS"
1,6928,"AIS"
[code]...
View 13 Replies
View Related
Jun 17, 2010
As much as I didn't want to ask a sed question, especially considering there's already one on this page I've looked as best I could and cant find the solution. Id like to use sed to replace occurrences of a pattern but exclude two or 3 specific lines that are not consecutive. For example I know with 1,10 i could exclude the first 10 lines, what is the syntax if I just wanted to exclude line 3 and 7. The sed command I'm working with right now is for rearranging Ethernets.
cat /etc/udev/rules.d/70-persistent-net.rules | sed -e '/'"$found1fullmac"'/!s/eth1/'"found1eth"'/' > /etc/udev/rules.d/70-persistent-net.rules
I would like to replace $found1fullmac with two variables representing line numbers to exclude from the replacement.
View 6 Replies
View Related
Jan 26, 2011
Can anyone offer a code snippet to recursively go through directories and replace any single or double quotes quotes found in a filename with another character (e.g. "_").If any of the filenames contain a single quote or double quote, then replace it with an underscore.
View 7 Replies
View Related
Jul 7, 2010
I am trying to launch the perl config, but when I do so I can an weird error.It seems to be that it does not regonize perl ?
conf.pl: line 11: =: command not found
conf.pl: line 19: my: command not found
conf.pl: line 20: syntax error near unexpected token `{'
[code]...
View 2 Replies
View Related
Aug 14, 2010
I recently reinstalled the B module for perl. Now I found out it didn't just do that, it installed a whole new copy of perl into /usr/local/bin/perl. When I type 'which perl' at the terminal, it says '/usr/local/bin/perl' instead of '/usr/bin/perl'. Normally, this wouldn't bother me. But I installed the one in local/bin without threading support. The one that comes with the system already is build with threading support, which is why I want to switch back to the system perl, and possibly remove the one in /usr/local/bin.
So how do I change it so that the result of 'which perl' returns as '/usr/bin/perl'? And what do I have to do to remove /usr/local/bin/perl?
The reason I need threading support is because I'm designing a file copier that copies several chunks of a file simultaneously to speed up the copying process. Guaranteed a useful script if it works.
View 7 Replies
View Related
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
Jun 28, 2010
I'm new in perl programming and linux OS. What is the difference between perl and perl-devel? What does mean devel? Iwant to install Catalyst and before install as required I have to check if make, gcc and perl-devel are installed in my system. make and gcc are installed. But I have to install perl-devel. First I searched for make, gcc and perl-devel in YAST Software Management and search did not find perl-devel. I visited the software.opensuse.org and wrote "perl-devel" and searched. The result was many similar zips with a prefix perl-devel and I can not choose one for needed perl-devel.
[Code]...
View 5 Replies
View Related
Apr 8, 2009
I am trying to setup the wlan access for my Fedora 9 system. I installed ndiswrapper. But when I run
Code:
ndiswrapper -l
i am getting the error
Code:
/usr/bin/perl: symbol lookup error: /usr/bin/perl: undefined symbol: PL_use_safe_putenv
View 11 Replies
View Related
Jun 2, 2011
I am unable to run perl-cgi script in my cent os Apache server. I have used locate perl command in terminal window and it gives following result:
[code]....
tell which is the path to perl for example "usr/bin perl"
View 13 Replies
View Related
May 11, 2010
I used a script that renamed my file eg 'echo webutil.olb | tr [A-Z] [a-z]' i wanted to rename it back to webutil.olb. How do i do this for many other files that i have
View 3 Replies
View Related
Jul 29, 2010
I want to search and replace strings in a file with strings in other files/i need to do it with big strings(string1 is big) and i want to use a txt file for this.But this code not working :
View 14 Replies
View Related
Oct 5, 2010
I Installed perl-doc in ubuntu 10.04 using sudo apt-get install perl-doc,in the same way I installed doc for postgreSQL. How to use perl-doc so that I can get from perl-doc.
View 2 Replies
View Related
Aug 30, 2009
I'm writing a bash script to search html files, and when I find any occurrence of an img src tag like this:
<img src="123-picture-normal.jpg" alt="some random user entered text" border="0">
I want to add a second line below it that looks like:
<img src="123-picture-thumbnail.jpg" alt="some random user entered text" border="0">
All I need to do is duplicate the line but replace "normal" with "thumbnail"
Each file can have multiple img src tags with different numbered jpgs.
I have a feeling this is a job for sed, but I'm struggling with it. Any ideas?
View 2 Replies
View Related