General :: Able To Grep For Names In A File That Contain Foo And Not BlahhFoo?
Feb 1, 2010
I have a number of files:FooBlahhFooI only want to be able to grep for names in a file that contain Foo and not BlahhFoo. However I am not able to pull only those files away. How can this bee done. My grep/zgrep knowledge only goes this far at this point. I'm still learning but I'm stuck on how to make my arguments more precise zgrep 'Foo' SomeFileIMade.gz > /home/user/FOOFILE
View 4 Replies
ADVERTISEMENT
Jan 10, 2011
I have a list of urls like code...
How can I use grep to match the domain names only?
All the urls have a / after the domain. And there are a lot of tlds, not sure how many, the list is quite big.
View 3 Replies
View Related
Nov 22, 2010
I need to kind of grep within grep. My input file would be something like:
[Code]....
and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:
[Code]....
View 4 Replies
View Related
May 11, 2011
I am supposed to take some small files, and print them to a specific printer, such that the small files are concatenated into one file. The file name has to be included in the file that gets printed.
Should I be looking to concatenate the files into one file with the file names included, and then print them?
something like: -printfunction -printername < file*
View 7 Replies
View Related
Oct 20, 2010
I have a considerable number of files in a subdirectory (some fascinating old military clips from archive.org - search on Big Picture if interested). Anyhow, I am downloading them using Internet Download Manager running in an XP virtual machine in VMWare on my Ubuntu 10.04 PC (due to the queuing, restart and speed capabilities of IDM). But I digress - the files are being saved on the host (Samba share) without a file extension. So I have a collection of files with names like
Quote:
The Douglas MacArthur Story
THEY WERE THERE (1960)
I wish to add the extension ".mp4" In Windows this is simply done with the command
Quote:
rename *. *.mp4
This of course does not work in Linux. I have researched the Linux rename command and reviewed a lot of examples. However, I have not found a way to add an extension to a batch of files which are named with no extension to start with. The spaces in the file names also seem to present an issue. At the moment I am renaming them from the Windows VM while they are sitting on the Samba share using the ancient File Manager program from Windows NT which works great on XP. I have experimented with the file rename facility in Gnome Commander however, it does not seem to want to do something so simple.
View 10 Replies
View Related
Feb 3, 2010
I have a file which contains a line like this:SERVER=10.205.110.19 How can I cut out the IP and assign it to a variable?
View 4 Replies
View Related
Sep 25, 2010
someone once told me that use can pass a file to grep and use that to search the contents of another file. if that is the case I'm not entirely sure why the following isn't working for me.
Code:
[root@LCENT01:~]#grep -i id_rsa.pub .ssh/authorized_keys
[root@LCENT01:~]#cat id_rsa.pub >> .ssh/authorized_keys
[root@LCENT01:~]#grep -i id_rsa.pub .ssh/authorized_keys
View 3 Replies
View Related
Dec 7, 2010
Let me *try* and explain what I'm trying to do, and keep in mind aside from a little command line stuff I'm a beginner to any of what I'm asking about.
I have a directory structure something like this:
Code:
/usr/local/chatlogs/
webserver1/
1.chatlog
2.chatlog
[Code]....
So that whatever was captured in the () in the first part of the statement would be used in the 1 in the back part of the statement for every n.chatlog that might be in any of the /webserver directories at that time.
View 2 Replies
View Related
Dec 31, 2010
I have collection my routers configuration through rancid. Now i want to do the following,
Display all the files that contain the following words
C1841 AND HWIC-4ESW
I want to display all the files that contains both these words.
View 14 Replies
View Related
Apr 4, 2011
I use the command line frequently to navigate my files so I try not to have spaces in file names. Typically I have used an underscore to connect words but it was recently suggested that I should use a dash. Are there any disadvantages to using an underscore in file names?Should I switch to a dash? My system is running Xubuntu and I almost exclusively use the bash shell.
View 4 Replies
View Related
May 26, 2011
I'm storing a list of strings in a file and would like to read the file and pipe each line returned to grep which in turn searches a directory for files containing the string.However this is not returning any output.
View 2 Replies
View Related
Jan 19, 2010
I am searching for Class declaration on a site with hundreds of PHP files, how can I do this in the current folder and subfolders using GREP?
I tested cding to the folder and then something like
grep -r 'class MyClass' *.php
View 5 Replies
View Related
Feb 16, 2011
I have following contents
I want to grep "#2" and want the output as
How to using shell script?
View 6 Replies
View Related
Mar 4, 2010
I wanted to grep the line in a file starts with -1.000000e+00.
Tried grep "-1.000000e+00" *, got error "grep: invalid option --".
Neither of the following works:
grep "-1.000000e00" *
grep "1.000000e00" *
How do I grep a negative number with scientific notation?
View 3 Replies
View Related
Mar 16, 2010
I ran into a bit of trouble making a bash script. (Desktop is a directory, and I try to get it's modification date)
Code:
lamp:~# cmd='ls -l Desktop | grep -o "....-..-.. ..:.."'
lamp:~# $cmd
ls: cannot access |: No such file or directory
ls: cannot access grep: No such file or directory
[code]....
When I type in the command directly, without using an inbetween variable, it works fine.
View 3 Replies
View Related
Sep 25, 2010
I would like to write a newline delimeted rules file using PCREs for use with the grep command. Grep has the option -f to obtain the search pattern from a file, and option -P to search using PCREs. However, these two options do not work together. The -f option only seems to work with fixed string rules.A friend previously helped me get around this limitation somehow, but I can't remember how he did it. I also would like the ability to add comments at the end of each rule in the file.
View 11 Replies
View Related
Feb 20, 2010
I am running gentoo openbox(rox file manager and desktop) I installed Digikam and Amarok. But I have problems with files which include special character in their names(such as �,�, �,ğ... ) The files are shown with strange and weird characters in the file dialogs of Digikam and Amarok.
I don't have this problem in other applications. I can create files with special character included. I think some settings do not agree with KDE4. How can I solve this problem? Does anyone have an idea? I also installed KDE systemsettings program but could not find a relevant config option for character encoding.
View 2 Replies
View Related
Jul 21, 2011
what is the file and path name of the configuration file to which you would add to the AllowUsers charlie linus lucy?
View 3 Replies
View Related
Jun 17, 2009
I have a list of words that I want to grep in many files to see which ones have it and which ones dont. in the text file I have all the words listed line by line, ex: list.txt:
check
try this
word1
word2
open space
list ..
I want to grep each line one by one. like I want it to
grep "check" *.log
grep "try this" *.log
grep "word1" *.log .. etc how can I do this?
and maybe write the output to a file.
View 5 Replies
View Related
Sep 24, 2010
I am attempting to grep the contents of a key file I have SCP'd to a remote server. I am able to cat it:
Code:
[bluethundr@LBSD2:~]$:ssh root@sum1 cat /root/id_rsa.pub
root@lcent01.summitnjhome.com's password:
[code]...
View 5 Replies
View Related
Oct 18, 2010
and how to list all files in a directory including full path, owner, group and permissions for each file
View 3 Replies
View Related
Jan 9, 2010
I use amarok 2 and I have a lot of files that are titled "Track #.mp3", in Amarok I have changed them to see as the real songs but the actual files are still the same. Is there a way to change the actual file names using amarok to match the tags I have inside of amarok? The reason why I'd want to do this:
1. If my home folder becomes corrupt I don't have to redo 100's of songs (I have a backup but none the less
2. If I ever decide to use another program or if I'm in W7 using Windows Media Player classic it'd be nice to have it recognize the correct files without having to double up on the tag editing
If this isn't possible I'm going to wishlist it because I think it's functional and having a bunch of Track# files is a pain but impossible to get around when you have a lot of mix cd's.
View 2 Replies
View Related
Apr 9, 2010
I have a problem with file names changes. I have a hundred of file with same names and different subdirectories. I want to change that file names by their subdirectery names.
Currently is:
file name------------------------subdirectory name
1_km_16_days_EVI_s2_01200_01200.img --> MOD13A2.A2000049.h23v03.005.dir
1_km_16_days_EVI_s2_01200_01200.img --> MOD13A2.A2000065.h23v03.005.dir
1_km_16_days_EVI_s2_01200_01200.img --> MOD13A2.A2000081.h23v03.005.dir
...
I want to
MOD13A2.A2000049.h23v03.005.img
MOD13A2.A2000065.h23v03.005.img
MOD13A2.A2000081.h23v03.005.img
View 3 Replies
View Related
Nov 22, 2010
I'm hoping that someone can help me, I need to remove spaces (not replace with underscores) from several thousand files on a system with cygwin.
Can I do this from the shell using rename or mv somehow?
View 4 Replies
View Related
Nov 20, 2010
How can we do a simple match by regular expressions on two filenames. I plan to use it in the command 'find -regex'
Code:
hosts.txt
ipaddress.txt
View 4 Replies
View Related
Nov 26, 2010
Kernel 2.6.21.5, Slackware 12.0
As a result of having mixed files from different filesystems, I have, in directory foo/, files with filenames in uppercase and files with filenames in lowercase. If I want to convert them to all uppercase how do I do it? Consider this will be later recorded into optical discs.
View 7 Replies
View Related
Jan 14, 2010
I would like to grep all values other than encrypted password from /etc/shadow fileFor example,each line consists of 8 fields separated with :/The only thing that I want not to print out is the contents between first : and second : (encrypted password)
View 7 Replies
View Related
Sep 12, 2010
how to update a series of values from multiple grep commands outputs to be appended to a single row of a csv file? Work on a linux envir. The values from grep output will be numeric values.
Output sold look like:
1,3,4,5,7,0,5
Each of these values will be odtained from multiple grep commands piped with wc -l Is it possible to update a single row of a csv file if so pleas ehelp me with the command to be used to redirect the output into the csv file
View 5 Replies
View Related
Feb 10, 2010
remove a line starting with specific word with grep. Here is what I found
grep -v '^cc$' data.txt
Here I remove all lines with on 'cc' in that line. But I want the result write back to data.txt
I try several ways
grep -v '^cc$' data.txt > output.txt # works but to another file
echo `grep -v '^cc$' data.txt` > data.txt # didn't work, all carets gone, become one line
grep -v '^cc$' data.txt > data.txt # data.txt is empty after running this
How can I save the result of grep to the input file?
View 4 Replies
View Related
Jan 30, 2009
I'm not sure if this is possible or even where to start. I assume that this can be done with an sh script using tar or similar.I have several very large zip files that contain images for all of the products in my online store. Each image is named after its 13 digit SKU (for example, 9987788000012.jpg). In order to import products into my store, all images are placed into a media directory. Unfortunately, there are over 100,000 images.
So I would like to break the images into sub-folders based on file name. For example, when I extract store_images.zip (or tar or whatever), my extract script would create directories (if they don't already exist) based on the first three digits of each image name, placing each image into the appropriate bottom level directory. For example, "9987788000012.jpg" would be placed in the following directory "media/9/9/8", with media as the root and "8" as the directory that holds any images that start with "998". Perhaps two sub-folders would be less cumbersome.Assuming this requires a script, particularly since it involves scanning image names, creating folders, and saving images to specific directories, which language would serve my needs best? PHP? Has anyone had to do something similar?
View 13 Replies
View Related