General :: Awk Varying Patterns To Different File?
Jul 29, 2011
Awk varying patterns to different file?
[Code]...
What I want to do is when the records have identical $3 i.e. same gene:blabla, I want to put them in a file with $3.out (P.S. along with the lines below it) I tried grepping out $3 first separately onto a file, and then taking each line in that file as a pattern and pulling out records using awk. Somehow I faced probs with pulling out onto $3.out
I need to grep the lines between pattern 1 and pattern 2 and not the lines following pattern 2. Cannot use grep -A(num), as there are varying number of lines following pattern 1. Also, used awk one-liners, but results are erroneous.
I am trying to compare a list of patterns from one file and grep them against another file and print out only the unique patterns. Unfortunately these files are so large that they have yet to run to completion. Here's the command that I used:
Code: grep -L -f file_one.txt file_two.txt > output.output Here's some example data:
I am interested in using the grep method in the shell of my CentOS machine to obtain patterns from a file and use them to search through another file and highlight the patterns found. For example:
I want to traverse a directory and get a list of files that contain a set of patterns. I assumed I could use grep for this, but I having trouble getting grep to only return files that match ALL patterns. Here's what I've come up with so far:
However, this gives me a list of files that match ANY of the patterns in the searchpatterns.txt file. I want to match ALL of the patterns. I've looked through the man page, but can't find anything that allows me to change the "OR" to "AND" for multiple patterns.
i have a problem about deleting a line from a text file which contains two specific patterns. i am using "sed -i "/$name/ d" peop.txt" but i must use one more variable which is surname.
and this is the code of text file. and the second question when i use "/$name/ d" it deletes not only the names which are macthing with $name but also all words that contain $name. so how can i fix these problems_?
I have a file with joker character patterns: ./include/* ./src/* etc. From the current directory I would like to recursively get the list of files that do not match these patterns.
I'm trying to use sed to search for a certain 'primary' pattern that may exist on several lines, with each primary pattern followed by an --unknown-- number of 'secondary' patterns.The lines containing the pattern start with: test(header_name)On that same line is an arbitrary number of strings that come after it.I want to move those strings over to their own lines so that they each are preceded by their own test(header_name).e.g. Original file (mytest.txt):
apples test("Type1", "hat", "cat", "dog", "house"); bananas
In Midnight Commander, is it possible to exclude some directories/patterns/... when doing search? (M-?) I'm specifically interested in skipping the .hg subdirectory.
I occasionally need to connect my laptop to different networks. I have an account on each of the machines, but as they are not coordinated, the UID of my account is different on each machine. Example
Machine.........Account UID Laptop..............501 Server 1............526 Server 2............517
When I connect to the server, I need to have access to my files and directories present on both that server and my laptop - both read and write. There is no problem getting exports setup, but how to I setup my connections such that I connect using the proper UID - or is there another mechanism to do this?I haven't done that much work with NFS, but I'm assuming this has to have been done
I noticed that one DVD I encoded to ogg (vorbis) resulted in files with varying volume levels (some files have sound much softer than others... and the original DVD is not like that). I wonder if it's mplayer or oggenc's fault. I do it like this (suppose):
Code:
for i in 01 02 03 04 05 ; do mplayer-vc null -vo null -ao pcm:filename=$i.wav dvd:// -title $i-$i; oggenc $i.wav $i.ogg; rm $i.wav; done I'm doing it by memory so I could have a mistkate or two in the sequence of commands but the idea is very simple
- Output the sound to a wav file using mplayer - Encode it with oggenc - Delete the wav file.
I remember using some dos program that would scan text files for particular words/patterns. It had an ncurses-like interface and if I'm not wrong its name was "Concord". Is there anything like that on linux? The main functionality was as follows:
1. support for regular expressions
2. print lines containing a particular word or pattern (highlighting it) and printing the surrounding lines.
3. print lines containing a particular word or pattern only if another pattern occurs within N words to the left/right.
The second point is easy to achieve in grep. The 3rd one could be done in awk. The problem is that as much fun as it would be to put it all together and embellish with some nice ncurses interface(eg. with dialog), I don't want to reinvent the wheel. Besides, I have just relocated and have been waiting for my phone line welcome pack for almost 2 weeks now (ie. no internet apart from work and mobile phone), which makes it difficult for me to get anything done.
I am trying to delete any blank lines within two patterns e.g.
Address: 53 HIGH STREET Cred Id : MYTOWN MYCOUNTY MM12 6MM Pay Method : Crossed Cheque
The start of my pattern is "Cred Id" and the end is "Pay Method" and I want to delete the blank lines between county and post code. I did find the code below but it doesn't seem to change anything:
sed -ne '/Cred Id/,/Pay Method/!bp' -e '/^$/b' -e -e p ll.out
I can get it to print just the range I'm interested in by doing sed -ne '/Cred Id/,/Pay Method/p'.
I have just installed ubuntu 10 on a thinkpad t410. At first everything worked swimmingly, INCLUDING the wireless. After about five minutes, the wireless stopped working, in that it seemed to think it was still connected but pinging didn't work. I've now restarted several times, and each time I restart, the wireless works for about 1 minute, then stops working. If I try to disconnect and reconnect it will not reconnect (until I restart, that is).
iwconfig shows the correct ESSID and ifconfig shows an address, and "connection information" shows a varying percentage of connection.
i have generated .exe file from C file (ie filename.c ) after compiling in linux machine with -O option. I wish to know about how to run that .exe file when linux system starts up ?
I work for a company that makes portable devices running Linux and I was recently asked to make the underlying file system read-only for "security" purposes. Since the distribution is based on LinuxFromScratch, I know that very little writing happens at run time. So, even if the device runs on a usb flash device, I doubt that putting the root file system RO will be that beneficial. I am actually more concerned about a process actually breaking because it cannot open a file in RW mode than a process going rogue and filling the root file system with log files, etc. I'd really like to ear what kind of advantages disadvantages there really is with read-only file-systems.
Can't log into my XFCE desktop like I normaly do. all the sudden I get notified that my xsession lasted less then 10 secondsLooking at the error I can see this:
Unable to access file /home/username/.iceauthority: No such file or directory
Using failsafe I can start a terminal. From terminal I tried to start X
Code: sudo startx Result: Running on desplay:0
So I tried to run this;
Code: sudo startxfce4 And I get up a graphical desktop.
So this is not a critical situation as I easily can use this method to log on, but as there has been something causing this I would like to be able to resolve this nonetheless. Btw it is not the old chmod trick in play here, cause my .iceauthority file is gone alltogheter.
I'm currently stuck at 6.13 GMP-5.0.0 of the LFS installation. After running make, I receive the following:
error while loading shared libraries: libbfd-2.20.so: cannot open shared object file: No such file or directory make[2]: *** [libmpn.la] Error 127 make[2]: Leaving directory `/sources/gmp-5.0.0/mpn'
I have just been bothered by a fairly small issue for some time now. I am trying to search (using find -name) for some .jpg files recursively. This is a Redhat environment with bash.
I get this job done though I need to copy ALL of them and put them in a separate folder BUT I also need to keep the order intact after copying.
For e.g - If I get a JPG file under /home/usr/new/1/ then the destination also needs to be /test/old/new/1/.
At the moment, I am simply putting all files under /test/old/ and I can't somehow get the later /new/1/ folder path created under /test/old/
I understand this could well be done using while OR if else loop, though if someone can just guide me with a hint, I would be really grateful.
I will complete the rest of the steps and was asking here since I am still not comfortable with the shell/bash scripts yet and planning to be really good at it over the next couple of months.
I need to get the modified date on a file in linux to use in a script.I tried using 'ls -l' on the file, but this caused problems when the date turned from a single digit into a double. The reason for the problem was because I was parsing the result string on spaces.How can I get the date of the last time a file was modified so I can use it in a script? For example, if a file was modified on 1/11/2010, I need the 11.
I am using xubuntu and there are a few types of files on website that instead of downloading and saving and then opening with emacs, I would rather when the radio button choice comes up say open with emacs. I am using xubuntu with xfce, and there is no line for a command to be entered as some ubuntu editions have. In the choice of changing the opening program from mousepad to something else, it says search and allows to navigate to find a program, but I cant find emacs anywhere not in etc/ or elsewhere. So where is its executable to direct the program chooser to?
I have a Linux (Kubuntu) system with a large (~20Gb) file which I would like to mess with. Specifically, I want to copy the entire contents of another large file (~12Gb) to the middle of this file, and keep the bits of the file which are not overwritten.This is what I want to happen, with the text between the pipes representing file contents:Before:
I had a situation in which the the path of the file to be copied is written in other file and I had to copy it using shell script..I can use cp $(cat /home/robert/location.txt) /media/sda1 on normal linux shell...But I am using buildroot script where $(cat /home/robert/location.txt) evaluate to nothing..is just blank..