grep for certain files using a file as input to grep and then move


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep for certain files using a file as input to grep and then move
# 1  
Old 12-10-2009
Error grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory ,

full file name -C20091210.1000-20091210.1100_SMGBSC3:1000 ,C20091210.1000-20091210.1100_LUD2:1000 ,

input file for grep SMGBSC3 LUD2 KSLI JIND ,

any help would be apprecaited .thanks
# 2  
Old 12-10-2009
Please explain the problem clearly with an example
# 3  
Old 12-10-2009
#!/usr/bin/awk
BEGIN {
FS = ",";
}

for field in inputFile
{
find . -name *field* | mv {} outputDir
}
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies

2. UNIX for Beginners Questions & Answers

How to iterate Grep via all patterns provided in an input file?

When I use the following grep command with options -F and -f, its just displaying the text related to only the last pattern. Command: $ grep -f pattern_file.txt input_file.txt Output: doc-C2-16354 Even the following command yields the same output: Command: $ grep -Ff pattern_file.txt... (6 Replies)
Discussion started by: nsai
6 Replies

3. Shell Programming and Scripting

Using perl to grep a list of patterns from an input file

I have been struggling to grep a file of NGrams (basically clusters of consonants or Consonant and Vowel) acting as a pattern file from an Input file which contains a long list of words, one word per line. The script would do two things: Firstly read a text pattern from a large file of such... (5 Replies)
Discussion started by: gimley
5 Replies

4. Shell Programming and Scripting

Which Grep to use a file as input?

I have two files: usednaslist & naslist Using RHEL5 usednaslist >filera:/vol/EQIMS/build >filera:/vol/iquad_dev/FAST_dev naslist >server12 SunOS filera:/vol/EQIMS/build /users/uxsrvlogs >servers3 SunOS filera:/vol/iquad_dev/FAST_dev /mnt >server4 SunOS ... (2 Replies)
Discussion started by: nitrobass24
2 Replies

5. Shell Programming and Scripting

Unix Script To Move Files Based On Grep

I am looking for advice on how to write a script that will rename and/or move files to a different directory based upon the results of a grep. Let's say I have ten files in a directory. Some of them - not all - contain the text 'HELLO'. I would like to be able to grep the files for that text,... (3 Replies)
Discussion started by: rjhjr64
3 Replies

6. Shell Programming and Scripting

Awk+Grep Input file needs to match a column and print the entire line

I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this). For example, i have a input file1.txt: cat inputfile1.txt 218299910417 1172051195 1172070231 1172073514 1183135117 1183135118 1183135119 1281440202 ... (3 Replies)
Discussion started by: poliver
3 Replies

7. UNIX for Dummies Questions & Answers

Using grep to move files that contain a line of text

I have a folder with about 4000 files in it. I need to extract the files that contain a certain line of text to another directory. for example files with 'ns1.biz.rr.com' need to be extracted to the directory above or some other directory. I tried using the following but was not successful. (6 Replies)
Discussion started by: spartan22
6 Replies

8. Shell Programming and Scripting

grep'ing for specific directories, and using the output to move files

Hello, this is probably another really simple tasks for most of you gurus, however I am trying to make a script which takes an input, greps a specific file for that input, prints back to screen the results (which are directory names) and then be able to use the directory names to move files.... (1 Reply)
Discussion started by: JayC89
1 Replies

9. Shell Programming and Scripting

grep files without header and move to new dir

Hi, i have number of files in a directory to be processed. the problem is some of the files does not have a header and the process is giving an error of no header found. example of good file : file1 HDR|20080803233401 record 1 record 2 TRA|2 example of a bad file in the same dir ... (6 Replies)
Discussion started by: sitaldip
6 Replies

10. Shell Programming and Scripting

How to grep in order based on the input file

Here is an answer rather than a question that I thought I would share. In my first attempt, I was using grep to find a list from file.1 within another file, file.2 which I then needed to paste the output from file.3 to file.1 in the same order. However, the results weren't what I wanted. At... (2 Replies)
Discussion started by: Kelam_Magnus
2 Replies
Login or Register to Ask a Question