Read contain files find and print to new file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read contain files find and print to new file
# 1  
Old 01-14-2015
Linux Read contain files find and print to new file

Hi All,

Sorrry by basic question but I have many files text plane e.g.

Code:
$ls  
file1 file2 file3 ..

etc.,
Code:
$cat file1

123
244
345
NNN
4234
QQQ
423534

How can read contain each file and find pattern NNN and print in new file output,

$cat newfile
NNN
QQQ


Thanks you,

Last edited by jim mcnamara; 01-14-2015 at 03:37 PM.. Reason: out
# 2  
Old 01-14-2015
What is ' file find pattern'?
1. a pattern in the file name
2. a pattern in the file's data

What is 'new file output'?
1. write to a new file
2. copy the file to a new location

Please give us a sample input and expected output from the sample input.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 01-14-2015
If I'm inferring correctly from that not quite specific request, try grep -o "^[A-Z]{3}$" file*
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

2. Shell Programming and Scripting

Compare two files and find match and print the header of the second file

Hi, I have two input files; file1 and file2. I compare them based on matched values in 1 column and print selected columns of the second file (file2). I got the result but the header was not printed. i want the header of file2 to be printed together with the result. Then i did below codes:- ... (3 Replies)
Discussion started by: redse171
3 Replies

3. Shell Programming and Scripting

For loop inside awk to read and print contents of files

Hello, I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
Discussion started by: jaldo0805
5 Replies

4. Shell Programming and Scripting

Read contents of the file and print

AT ---------- 0 Elapsed: 00:00:00.02 SO ---------- 0 Elapsed: 00:00:00.01 SE ---------- 0 Elapsed: 00:00:00.01 CR ---------- (4 Replies)
Discussion started by: sandy1028
4 Replies

5. Shell Programming and Scripting

Read a text file and print the content..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... ... (7 Replies)
Discussion started by: samupnl
7 Replies

6. Shell Programming and Scripting

I need to find one command from multiple files and need to print that file which contains neede com

Hi all i need your help .. I am having a multiple file in directory and i have find out the Rcopy word from these files and need to print those files which contains the Rcopy word Thanks and regards Vijay sahu (2 Replies)
Discussion started by: vijays3
2 Replies

7. UNIX for Dummies Questions & Answers

find locked files, print file path, unlock file

using OS X and the Terminal, I'd like to find all locked files in a specified directory, unlock them, and print a list of those files that were unlocked how can I do this? I'm familiar with chflags nouchg for unlocking one file but not familiar with unix enough to do what I'd like. Thanks! (0 Replies)
Discussion started by: alternapop
0 Replies

8. Shell Programming and Scripting

Need shell script to read two file at same time and print out in single file

Need shell script to read two file at same time and print output in single file Example I have two files 1) file1.txt 2) file2.txt File1.txt contains Aaa Bbb Ccc Ddd Eee Fff File2.txt contains Zzz Yyy Xxx (10 Replies)
Discussion started by: sreedhargouda
10 Replies

9. Shell Programming and Scripting

read input from 2 files and print them in alternate columns

Hi Frnz Please help me out. I have two text files. A.txt one two three four B.txt Jan Feb Mar Apr I need the output as (1 Reply)
Discussion started by: sriram.s
1 Replies

10. UNIX for Dummies Questions & Answers

list read only files using find

hi, how can i list read only files (for u,g,o) using find command? Thanks and Regards Vivek.s (1 Reply)
Discussion started by: vivekshankar
1 Replies
Login or Register to Ask a Question