General :: How To Get List Of Files Not Matching Patterns In Bash
May 4, 2011
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.
View 2 Replies
ADVERTISEMENT
Aug 13, 2010
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:
Code:
>FQ4HLCS01BMR4N
>FQ4HLCS01BZNV6
>FQ4HLCS01B40PB
>FQ4HLCS01BT43K
>FQ4HLCS01CB736
>FQ4HLCS01BU3UM
>FQ4HLCS01BBIFQ
how to increase efficiency or use another command?
View 14 Replies
View Related
Sep 13, 2011
I have many files in a folder for example
Kiran.txt
Kiran1.txt
Kiran221.txt
Kiran144.txt
Time.csv
[Code]...
From this directory, I want to know how I could use grep to display files based on part of their filename - for example those starting with "Account" or those ending in ".sh".
View 4 Replies
View Related
Jan 20, 2009
I'm having a small issue with regex matching in Perl. I'm pretty certain it's a simple fix, but it all looks correct to me...
If I run the following:
Code:
It prints out all the lines containing a 'P', as one would expect. But when the regex is
Code:
I get zero lines printed. It seems to match only single-character patterns.
The file I'm reading is: (It has the same effect whether I leave it with Windows linebreaks or convert them to unix).
Code:
View 3 Replies
View Related
Jul 12, 2009
Is there a way, preferably in python or BASH, to rename files from a list? for instance, track1.mp3, track2.mp3 should be renamed to the names stored in a file listing song names. I have tried to loop a variable through directory listing and renamed them, only to find that filenames with spaces can't be assigned to a variable as a whole. To solve the problem above, I have tried the read command in BASH, which enables the program reading line by line from a list. However, It was failed to pipe the results from directory listing to the read command.
View 14 Replies
View Related
Apr 5, 2010
I'm trying to write a bash script that gets the list of files in a directory and puts them into a variable, then checks each entry and outputs them as follows:
item1 is a FILE
item2 is a DIR
item3 is a DIR
etc etc.
I am able to get the list of files into a variable, but unsure how to get the output I want.
View 3 Replies
View Related
Jun 9, 2010
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:
Code:
grep --recursive --file=searchpatterns.txt --files-with-matches somedirectory/*
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.
View 5 Replies
View Related
Dec 27, 2010
How can I convert a file with a lot hex numbers into the decimal?
Example: file1
0x59999
0x5acdc
0xffeff
I want to start $ cat file1 | util | cat >file2 and get file2 with smth like
[Code]...
View 3 Replies
View Related
Dec 8, 2010
I am an uploader to a various hosts, so this tiny script me a lot. I make a rar archive and split files with 100mb. I could get 3-4 or even 76 parts of rar files and it would take me some time to paste all these urls to remote upload function of filehosting sites. For example:
Code:
server:/home/cober/downloads/teevee# ls -al
total 358784
drwxrwxrwx 2 root root 4096 Dec 8 19:38 .
[code]....
View 1 Replies
View Related
Dec 6, 2010
I'm writing a bash script to copy a list of files and do some stuff to them. Basically, I have the code written that does what it needs to do, but I can't quite understand why it works. I was hoping someone could clear up my understanding a bit.
Code:
The first line generates a list of files. I wrap each line in quotes because they usually have spaces in the directory names.
The second line changes IFS, and I understand what IFS itself does. What I don't quite get is what the separator becomes with that echo statement. If I'm reading that correctly, the backspace will remove the newline and essentially the result is nothing? I found this solution on a web page somewhere, but it was years old and there was no real explanation.
View 1 Replies
View Related
Aug 25, 2009
need a command or script to list all files recursive without directories one line per file, no extra lines like ls -AR1 should print file size and name eg.:
12 file.ext
25684 file2.ext
589 file3.ext
...
View 7 Replies
View Related
Mar 13, 2011
I have a requirement to list files using find command My folder contains below list of files with out extention.I have a requirement to exclude only ABC.123.* type files and list others. Even though files having MNO contains this pattern i should not exclude. Even if file ends with .txt or .doc it should not be excluded. That is ABC.123.1234.txt should not be excluded.But I am not getting what is required. Can any one please let me know if I am doing wrong any where. As per my requirement I cannot use grep, -regex, or -regex attributes to find command.
View 7 Replies
View Related
Feb 22, 2010
How can I remove all .swp files in all of my subdirectories under Linux?
View 4 Replies
View Related
Jul 19, 2011
If I wanted to copy all *.so files from src to dst I'd do:
cp src/*.so dst
However, I want to copy all *.so files from src and it's subdirs into dst.
View 2 Replies
View Related
Oct 18, 2009
I'm trying to do something very basic in bash. It's a kind of cross-reference matching between 2 files. I have a file1.txt. It's like this:
Code:
item1
item3
item4
...
I Have a file2.txt. It's like this:
Code:
item1 "Properties of item1"
item2 "Properties of item2"
item3 "Properties of item3"
item4 "Properties of item4"
item5 "Properties of item5"
...
My goal is to print out the lines in file2 that contains lines present in file1. I do:
Code:
for i in $(cat file1.txt); do grep $i file2.txt; done but I get no output. Will someone please tell me where am I mistaking?
View 3 Replies
View Related
Mar 14, 2010
How to build a list of files under a directory that may have any permissible characters in the name, that is anything except NUL? The only possible (?) bash data structure to contain a list of such names is an array because NUL cannot be used as a list item separator so no X-separated list can safely be used; there is no "X" that might not be part of a file name. OK -- but how to populate such an array? Here's what I've tried.
Code:
#!/bin/bash
# Set up test files
dir=$(mktemp -d "/tmp/${0##*/}.XXXXXX")
touch $dir/foo $dir/bar
[code].....
View 10 Replies
View Related
Feb 11, 2011
I have 2 massive duplicate dirs of the same format as below:
dir1
subdir1
file1
subdir2
file1
subdir3
file1
...
Dir2 is the same, but it has some newer files of the same name. I want to copy all file1's from Dir2 to the same name and folders in dir1. So basically something like:
cp -pr bkpDir1/*/*-big.gif Dir2/*/*-big.gif
This works for singular cases:
cp -pr bkpDir1/uniquesubdir/*-big.gif Dir2/uniquesubdir/*-big.gif
But not for wildcards:
cp -pr bkpDir1/subdir*/*-big.gif Dir2/subdir*/*-big.gif
Anyway the aim is to do the first cp above, I have tried a few options using find. In trying to show an example stumbled upon a way that worked, while in dir2:
find */*-big.gif | xargs -i cp -rp {} ../dir1/{}
Sure there are better ways also...
View 1 Replies
View Related
Apr 16, 2010
I am writing a shell script that finds all files named <myFile> in a directory <dir> or any of its subdirectories, recursively. I also need to take care of symbolic links that may form cycles, to avoid infinite loops. I am not supposed to use find command for the same
I started writing the code but got stuck. I thought using recursion may be a smart way, but its not working.
Code:
#!/bin/sh
findFiles()
{
thisDIR=$1
#cd $thisDIR
code....
View 5 Replies
View Related
Jul 22, 2010
AKA "zipping on the fly .. the slow-as-molasses way." The list includes full pathnames to each file, and they're all in subfolders of the same parent folder (which, unfortunately, is not the root folder of the drive or system on which the files reside). A cleaned-up and radio-ready portion of the list looks like
Quote:
.../taiga/ahqr-va-choyvp/bv0884-073.jpg
.../taiga/ahqr-va-choyvp/bv2635-073.jpg
.../taiga/ahqr-va-choyvp/bv3067-175.jpg
[code]....
What I'd like to be able to do is zip all the files in the list into a single archive, to avoid the step of having to copy them to the same location (presumably another folder on the HD) and then zip that folder. I'm more inclined to make provisions about extracting to a single folder at some other time. Is this possible in BASH, or would I have to consider a faster, more robust scripting language such as python or perl?
View 8 Replies
View Related
Apr 3, 2010
I'm searching within Java files for some occurrence of a phrase:
find . -name '*.java' | xargs grep -l 'string'
How do I change this command to print to the shell all of the lines which contain a match?
View 4 Replies
View Related
Jul 22, 2010
What is the best and simplest way to compare two directory structures without actually comparing the data in files. This works fine:
diff -qr dir1 dir2
But it's really slow because it's comparing files too. Is there a switch for diff or another simple cli tool to do this?
View 4 Replies
View Related
Jan 13, 2011
In a bash-script, only the case if a regular expression does not match is relevant.herefore I used the exclamation mark !. But where to place it?
These two work fine, but are they equivalent?
Code: if ! [[ $abc =~ $pattern ]]; then or
Code: if [[ ! $abc =~ $pattern ]]; then Where is the ! placed more correct?
View 2 Replies
View Related
Mar 27, 2011
In a bash shell script, I want to do something like this:
Code:
if [[ $(ls -ld /some/dir/foo_* | wc -l) -gt 4 ]]; then
rm -rf first_match_of /some/dir/foo_*
[code]....
View 6 Replies
View Related
Apr 25, 2011
If I have files named like this:
abc_one.c
egx_two.c
tsf_two.c
[code]...
View 9 Replies
View Related
Mar 19, 2010
Here is a LIST:
List = "abcd 1234 jvm something"
How to get the second element "1234" without looping all the list?
View 2 Replies
View Related
Aug 2, 2011
how to list existing users using bash
View 8 Replies
View Related
Sep 14, 2011
Is there any way to list just the folders in a directory using bash commands? ( as the ls command lists all the files and folders )
View 3 Replies
View Related
Sep 11, 2009
I am trying to do a find/grep/wc command to find matching files, print the filename and then the word count of a specific pattern per file. Here is my best (non-working) attempt so far:
wc `find . ( -name "*.as" -o -name "*.mxml" ) -exec grep -H HeightResizableList {}` ;
View 10 Replies
View Related
Jun 7, 2010
I need to figure out a bash command to list all users logged in at or after 5pm - 5pm being the specifier in the command.
Code:
Command seems to be the easiest way to display users but it specifies all users log times.
I've also fiddled with the lastlog command to no avail.
View 2 Replies
View Related
Sep 2, 2010
I have been using comm to compare two simple column lists, and suppress items that were contained in the second list (suppression list). This was extremely simple and basic, however now list1 has two columns, and I must compare the second column in list1 with my suppression list.
Basically I need to compare my user list and suppression list to suppress any users that exist in the suppression list, then remove the second column (md5).I wasn't sure the fastest way to make comparisons if there was a similar command like comm, or if I needed to create an array of users and see if any of them matched the suppression list one by one. This seemed like it would be pretty process intensive. Anyone have any less cumbersome ideas?
View 6 Replies
View Related