Search and paste a line..


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Search and paste a line..
# 1  
Old 06-07-2005
Search for a keyword in a line then output the line

Hi everyone, I've never used Unix ever in my life and I just got a summer job that requires me to manipulate Unix =(

I'm currently encountering a problem...
I need to search for Keyword in a text file, and if I find Keyword , I'll have to output the whole line that contains Keyword into a new text file. I know it can be done with a If-then statement...but I don't know the syntax, could someone please help me? Thanks!

Last edited by SeanDM; 06-07-2005 at 05:12 PM..
# 2  
Old 06-07-2005
grep Keyword textFile > newFile
# 3  
Old 06-07-2005
Thanks!!! I thought grep only finds a single word instead of a line, but thanks anyways!!! That really helped a lot!
# 4  
Old 06-07-2005
Grep outputs the full line of any line it finds in a file contining keyword

If you learn regular expressions (woohhooo I love em) then grep is something you will pine for on windows machines (yes I know you can download "grep for windows")....
# 5  
Old 06-07-2005
Quote:
Originally Posted by SeanDM
Thanks!!! I thought grep only finds a single word instead of a line, but thanks anyways!!! That really helped a lot!
'grep' stands for GlobalRegularExpressionPrint as in 'g/re/p'
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Writing a search, copy and paste program

Hello, Can some one help me by writing me the script of a program that does the following simple functions on a Linux Mint: 1. it runs in the background all the time, doing nothing except of checking if there is any external device mounted. 2. when the device is detected, it copies files... (1 Reply)
Discussion started by: Black_Ardilla
1 Replies

2. Shell Programming and Scripting

Copy some line and paste it after some line in same file

Hi, I want to know how I can copy line 6th to 10th and paste it after 17th line in same file. Thanks, Biplab (19 Replies)
Discussion started by: Biplab
19 Replies

3. UNIX for Dummies Questions & Answers

vim copy line and paste at the beginning, middle, and end of another line

How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Discussion started by: cokedude
3 Replies

4. Shell Programming and Scripting

Paste every other line?

Hi! I have two files that look like this: File1 A B C D E F ... File2 Z Y X W V U (4 Replies)
Discussion started by: Limmnes
4 Replies

5. Shell Programming and Scripting

Can't paste in command line.

Hello. I've made a simple script which asks the user to input a hash and then runs a command that replaces the variable $hash with what the user inserted. The ting is that when the programm asks for input I can't paste anything there..! any clues?? :wall: (8 Replies)
Discussion started by: louboulos
8 Replies

6. Shell Programming and Scripting

sed help - search/copy from one file and search/paste to another

I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ... (5 Replies)
Discussion started by: ncwxpanther
5 Replies

7. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

8. Shell Programming and Scripting

Vi Editor - How to paste the line concatenated with current line

I generally use yy to copy a line and then p to paste the line at end of current line. But is there a way to paste the copied line in concatenation with the current line with out going to next line. (3 Replies)
Discussion started by: paragkalra
3 Replies

9. Shell Programming and Scripting

Search, copy and paste

Can i search in a file for more than one string at a time? And copy the next string after that and paste it in column style? Is it possible? Thanks! (4 Replies)
Discussion started by: kingpeejay
4 Replies

10. Shell Programming and Scripting

copy and paste a specific line

Hi I am having some trouble cut and paste a file based on the content of another file. I have a file called draft. I need to cut and paste its content to another file based on the content of a file called proc.txt The content of proc.txt is like the following:... (7 Replies)
Discussion started by: tiger99
7 Replies
Login or Register to Ask a Question