Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to export some lines from a file to a new file? Post 302723373 by pamu on Tuesday 30th of October 2012 03:26:00 AM
Old 10-30-2012
Quote:
Originally Posted by phamnu
grep 'F(tot: 1' ft.09 F1.txt
I created the file F1.txt before the grep command.
Using Elixir's code you don't need to create file before grep.

Code:
grep 'F(tot:  1' ft.09 > F1.txt

If you want to append data into the file then just use >> instead of >.Smilie
This User Gave Thanks to pamu For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

2. Shell Programming and Scripting

Extra/parse lines from a file between unque lines through the file

I need help to parse a file where there are many records, all of which are consistently separated by lines containing “^=============” and "^ End of Report". Example: ============= 1 2 3 4 End of record ============= 1 3 4 End of record Etc.... I only need specific lines... (5 Replies)
Discussion started by: jouuu
5 Replies

3. Shell Programming and Scripting

How to export a unix file to txt file?

Is there any way by which u can export a file in unix box to a notepad or txt file?:confused: (3 Replies)
Discussion started by: nohup
3 Replies

4. Shell Programming and Scripting

bash mysql export to file

I'm trying to export a mysql query to a .csv file, right now I'm running a successful query like: us_id=`mysql -u $USER_NAME --password=$PASSWORD -D "databasename" \ -e "SELECT * \ FROM databasename.table \ WHERE somefield >0 AND otherfield ='$ctry' \ ORDER BY... (1 Reply)
Discussion started by: unclecameron
1 Replies

5. Shell Programming and Scripting

help t export the variable from a particular file

Hello Guys, I need you help to do one task I have script which is actually doing to fetch the code of any repository in svn for e.g.:- I can use svn to checkout the repository but I want to checkout the repository for particular tag like svn co <url>/svn/repo/<tag-name> and this... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

6. Shell Programming and Scripting

Extract some lines from one file and add those lines to current file

hi, i have two files. file1.sh echo "unix" echo "linux" file2.sh echo "unix linux forums" now the output i need is $./file2.sh unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

7. AIX

wtmp file - is there a patch to export the data another file each day?

sorry for being a noob, i am trying to find which user accessed the server at what time and there ip address at first i used who command but the output didn't contain the ip address then i used the last command which provided me with the ip of the users but when i searched i searched and found that... (1 Reply)
Discussion started by: hercules_1010
1 Replies

8. Shell Programming and Scripting

How to export the string to a text file.

Hi, I have used this find . -type f -exec grep "491629461544" {} \; > test.txt to find the string and export it to file. The problem is, when i used the above command in Shell script, the file is created but the searched string is recursively written in that file and even the file... (10 Replies)
Discussion started by: nanthagopal
10 Replies

9. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies

10. Shell Programming and Scripting

If the 1th column of file f1 and file f2 is the same, then export those line with maximum string of

please help to write a awk command-line programs to achieve the following functions: Thank in advance. Requeset Description: compare two files f1 and f2, export to file f3: 1 Delete duplicate rows of in file f1 and file f2 2 If the 1th column of file f1 and file f2 is the same, then export... (1 Reply)
Discussion started by: weichanghe2000
1 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy