But I want it to return just "0m1.001s", the portion is the group. I can just apply egrep to whatever the first command returns but is there an easier way to do it?
I have an interesting problem, sed '/pattern/{n;p;}' file, doesn't seem to be catching all of the matches in my file. As an example of this see below.test:
I am trying to create a shell script, on taking a input file as parameter, which need to do 3 things
1) create a copy of existing file.
2) add a new line to the copied file.
3) strip off all the absolute paths inside the copied file
The first 2 points are straight forward. but i am finding it difficult to acheive the 3rd point. myself not very good with awk and sed. but gave it a shot in vain. For example, the input script consists of below,
I have a file, say abc.txt, whit some text lines.The I have a second file, say 123.txt where at a certain point one can read "WORD".I would like to append the whole content of abc.txt (as it appears in abc.txt) in the line after "WORD".
Is it possible to allow a group/user to execute a command, where one of the parameters of the command is a group as well? example that does not work as intended:
Code: Cmnd_alias SU=/bin/su -l %group1 This example works sortof, it treats the "%group1" literally. I know I can list out the "/bin/su -l <eachuser>", but as you can imagine that is impractical. In this example, I want people in group2(not shown for brevity sake) to be able to su to someone in group1
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'm writing a script that edits a Maya ascii file. Inside the .MA(maya ascii file) there is a line defaultRenderGlobals. My script is supposed to find this line and according to what options they manipulate will update the lines below defaultRenderGlobals. I've got that working... but... the issue i'm having is that defaultRenderGlobals is only made when a the maya scene is made into a batch render. I want my script to manually addefaultRenderGlobals line into the .ma file if its not there and add the certain lines below it.RenderGlobals is already there I want to just manipulate whats below it. Hope this makes sense
I want to search a file for a particular pattern and if pattern found replace the line with new text. i am using awk 'match($0,"pattern") != 0 {print $0} ' filename to check if the pattern exists.how do i get the line number of the pattern and delete that line and replace the line with my new text?
I have to enhance the behaviour of a backup script written in perl. I don't need to change it, what I need to do is to create a bash script that does some checks like file name and file size, execute the backup script then check if the backup files match the original files.Here's how I try to do it:
- read the files from the original files folder - store them in an array - search in the array the files that have a specific file extension - store the file names that match the search pattern (I know the backup script skips some files so I can hardcode the search pattern) - run the backup script - read the files from the backup folder - store them in an array - compare the original files name and size stored in an array with those from the backup folder - send a report email
I want to list all the files that don't have a copy with the same filename with -1 somewhere in it. So, in the example above, the results would be 3.png.
NB: the file and its copy with "-1" in it will be the same filesize, if that helps.
Here's the actual line of code, which exists in a bash script:
Code:
I want to replace instances like this:
Code:
with this:
Code:
Using this:
Code:
Which works great when there's only ONE of the pattern on the line. But in a case like the "actual line" I posted first, where there are two patterns, separated by a slash, only ONE gets replaced
Watch:
Code:
Why? There must be (among many other things) something I'm not knowing about sed, that's causing this.
-- I'm currently using the ~ (tilde) as the separator in the sed command. It doesn't matter, I've used / ~ and % with no difference.
-- As a test, I tried putting a different character(s) in the middle of the original pattern instead of the / but that made no difference.
-- I've come up with various similar but slightly different regexs that will do this replacement, but they all have had this same result.
-- I tried the sed single-quoted, double-quoted, and unquoted; the latter fails to execute, and the formers both work as described here: wrong.
I want to go through a log file and find pattern1 and then a pattern2 only after pattern 1.So for example I want to know howManyRecords was in 13:30.I figured I grep for "start time for the job" and then only after that (and before the next occurence of that) grep for "howManyRecords". Is this a sane way?
I am testing the serial ports on a Single Board Computer(SBC) running Linux kernel 2.6.29. I usually do this by connecting the serial port to another PC serial port, then doing "cat /dev/ttyS0" on PC and "echo hello > /dev/ttyS0" on the SBC. However in the current system, "echo hello > /dev/ttyS0" command does not return at all! Also no characters appear on the destination port. I am running the echo command as root. The system boot messages show that the serial port in indeed /dev/ttyS0.
I need to get a return code for the command ldapmodify.I try this and didn't workrc=ldapmodify -a -v -c -p $PORT -h $SRV -D cn=$USR,cn=Users,dc=company,dc=com -w $PWD -f $LDIFFILENAMECOUNTecho "return code " $rc what exactly the way to get the return code of that ?
How can I pass carriage return to a command. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (ie. press Enter button) to this command. Is tehre any way
I'm creating a usb device driver that needs to be able to read from two different endpoints. I couldn't see any way of having two read functions in the driver, so I got round this by reading from one of the endpoints with read, and the other with ioctl.However this hasn't worked, the ioctl call from c returns -1. I added a printk command in the driver in the ioctl function, however looking at kern.log I can see that this function is never being called. Does anyone have any ideas as to what the problem called be, or a better method of being able to read from two different endpoints?
Below is an example output of what I see when I run the 'ls' command on some directories in linux (this is from a tomcat/common/lib directory). However I'm not clear on why some of the filenames are appearing inside [square brackets]
But in this way the command console will keep hang. Now I want to write a script which calls u this command and return back to the command console. Here is what I wrote but it doesn't return back to the command console:
Code:
#!/bin/sh MSGBP_HOME="/opt/jboss/MSGBP" case "$1" in start)
How can I pass carriage return to a command in the shell script. I am writing a shell script whcih generates ssh key pair. It ask for input from user three times. I want to pass carriage return (i.e., press Enter button) to this command.
I have several (vhdl) files containing a pattern with newline characters that I need to replace by another pattern that also contains newline characters.
I start with something like:
Code:
I want to replace it by something like:
Code:
(I need to paste some lines)
As I need to do this (very) often I want to use a shell script.
i've configured my pc using 'sudo pppoeconf' and it worked fine, but when i rebooted my pc and tried to connect using 'pon dsl-provider' it says 'Error: only members of the 'dip' group can use this command'. I've added myself to the group and tried to connect but to no use.Im able to connect in windows without any issues.
I'm trying to allow a specific group on my machine to execute one command with sudo without requiring a password, so what I want to do is add something like this to sudoers:
%groupName ALL = (ALL) NOPASSWD: /bin/bash /path/to/shfile.sh argument1 argument2
argument1 needs to be a url : http://subdomain1.subdomain2.domain.com
argument2 needs to be a path of the form /var/www/demo/SomeFolder/application/config/config.php
How do I put in a regex form that sudoers will understand ? I tried reading the sudoers manual, but it didn't help a lot .