Redirect lines to another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirect lines to another file
# 1  
Old 10-30-2010
Redirect lines to another file

Hi,

I have a file with a size of 10 mb and I need to redirect some specific lines to a new files. For eg.
Code:
Executed Restore for 11227.EDCS.551.01.201110 from /tmp/bk/restore/CR81500/content/S24U15VA2.2010-10-29.16:49.EDT/ArchiveFile_11227.EDCS.551.01.201110.zip
Operation output:
<U+FEFF>Oct 30, 2010 2:49:15 AM - Fatal: A fatal error has occurred. The reason for the error is:
        Restore operation requires a new destination course.

The files contains the lines like the above. I need to redirect the similar lines in a file to another file using the shell script.

Last edited by Franklin52; 10-31-2010 at 10:35 AM.. Reason: Please use code tags
# 2  
Old 10-30-2010
hi
these lines are sequential or not? and each lines are seperate or continuation lines?
# 3  
Old 10-30-2010
1) These lines are not sequential.
2) These are totally four lines, the first 2 lines belongs to the 1st line, 3rd as 2nd line 4th line as 3rd and 5th as 4th as per in the forum display.
3) My suggestion is, by keeping the first word of the line "Executed Restore" and last word of the line "destination course" we can copy and redirect it to the another file.
# 4  
Old 10-30-2010
try this
Code:
# sed -n '/Executed Restore\|Operation output\|The reason\|destination course/p' infile >newfile

# 5  
Old 10-30-2010
Try:
Code:
awk '/^Executed Restore/,/destination course.$/' infile

Code:
sed '/^Executed Restore/,/destination course.$/!d' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Redirect to a file

Hi, Is there a way to redirect the output of a set of commands to a file instead of using << at every command in bash shell. For eg (echo hostname echo "Comparing 2 files" comm -3 file1 file2) >>file3 (3 Replies)
Discussion started by: Rossdba
3 Replies

2. Shell Programming and Scripting

Read file from input and redirect to output file

Hi , i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names for eg: file.txt contains file_name1.txt|hai file_name2.txt|bye file_name3.txt|how... (3 Replies)
Discussion started by: rohit_shinez
3 Replies

3. Shell Programming and Scripting

ksh- redirect stderr to file and then modify the file

I have the following: remsh $host -n 2>>syslog_issue_list.txt grep -i -e "EMS" -e "error" -e "warning" -e "excessive" /var/adm/syslog/syslog.log | awk /"$DATE1"/ | awk -vhost="$host" '!/remsh|telnetd/{print host "\n", $0 >> "syslog_issue_list.txt"}' I am creating a health script that has... (4 Replies)
Discussion started by: chipblah84
4 Replies

4. Shell Programming and Scripting

How to redirect output of ls to a file?

Hi All, I want to redirect only the file names to a new file from the ls -ltr directroy. how Can i do it. my ls -ltr output will be as below. -rwxr-xr-x 1 118 103 28295 Jul 26 2006 event.podl -rwxr-xr-x 1 118 103 28295 Jul 26 2006 xyz.podl I want my new file... (6 Replies)
Discussion started by: girish.raos
6 Replies

5. AIX

Grep multiple lines and redirect to file

I have setof files with data and with same fields multiple times in each of the files. for example: file 1 name = mary kate last name = kate address = 123 street = abc name = mary mark last name = mark address = 456 street = bcd file 2 name = mary kate last name = kate... (2 Replies)
Discussion started by: relearner
2 Replies

6. Shell Programming and Scripting

TOP redirect to file

Okay, this is what I have and what I need. top -p 11111 >> test.txt Unfortunately, when I do that in a script, when I run my next command, could be just an 'ls -l' it says that the process stops and it doesn't write to the test.txt file anymore. I guess the first part isn't as big of a... (5 Replies)
Discussion started by: cbo0485
5 Replies

7. HP-UX

how to redirect the growing contents of log file to another file in unix

how to redirect the growing contents of log file to another file in unix (2 Replies)
Discussion started by: megh
2 Replies

8. HP-UX

How to Redirect the error messages from Syslog file to our own Application Log File

Hello, I am New to Unix. I am Using HP-UX 9000 Series for my Application. I am Currently Facing an Issue that the error messages are being written in the syslog file instead of the Application Log File. The Codes for that Syslog.h is written in Pro*C. I want to know how to Redirect these... (3 Replies)
Discussion started by: balasubramaniam
3 Replies

9. Shell Programming and Scripting

Cronjob - Redirect mail output to file, LINES & COLUMNS

I currently have an expect script that issues the 'mail' command and sends an 'x' when it receives the & prompt from mail to quit. The expect script is able to do stty rows 100 columns 200 < $spawn_out(slave,name) to set up the number of columns and rows. I would like to get rid of the expect... (0 Replies)
Discussion started by: jharvey
0 Replies

10. UNIX for Dummies Questions & Answers

How to redirect duplicate lines from a file????

Hi, I am having a file which contains many duplicate lines. I wanted to redirect these duplicate lines into another file. Suppose I have a file called file_dup.txt which contains some line as file_dup.txt A100-R1 ACCOUNTING-CONTROL ACTONA-ACTASTOR ADMIN-AUTH-STATS ACTONA-ACTASTOR... (3 Replies)
Discussion started by: zing_foru
3 Replies
Login or Register to Ask a Question