09-26-2009
grep N lines after match and then print them on 1 line each
Hello
I need some help with this job.
file.txt
----- cut ----
TARGET
13/11/08
20:43:21
POINT 1
MOVE 8
772102y64312417771
TARGET
13/11/08
21:10:01
POINT 2
MOVE 5
731623jjd12njhd
----- cut ----
this is the example.
i need to grep for the word TARGET and print next 4 lines like that:
TARGET 13/11/08 20:43:21 POINT 1 MOVE 8
TARGET 13/11/08 21:10:01 POINT 2 MOVE 5
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. UNIX for Dummies Questions & Answers
Hello
I have a silly question. I need to grep a match in text file
and then print 5 lines after it.
grep -A 5 .... do it.
OK
The next thing I can not handle is I need each output to be on 1 line
match line2 line3 line4 line5
match line2 line3 line4 line5
etc..
I will really... (10 Replies)
Discussion started by: alekkz
10 Replies
3. Shell Programming and Scripting
Hi folks,
I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies
4. Shell Programming and Scripting
Data:
Pattern Data Data Data
Data Data Data
Data Data Data
...
With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
Discussion started by: dmesserly
9 Replies
5. Shell Programming and Scripting
Hi Guru's,
I am trying to grep a range of line numbers (based on match) and then look for another match which starts with a special character '$' and print the line number. I have the below code but it is actually printing the line number counting starting from the first line of the range i am... (15 Replies)
Discussion started by: Kevin Tivoli
15 Replies
6. Shell Programming and Scripting
Hello Experts , require help . See below output:
File inputs
------------------------------------------
Server Host = mike
id rl images allocated last updated density
vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies
7. Shell Programming and Scripting
I need to fetch particular string from log file based on grep condition match.
Actual requirement is need to print the next word from the same line based on grep string condtion match.
File :Java.lanag.xyz......File copied completed : abc.txt
Ouput :abc.txt
I have used below... (5 Replies)
Discussion started by: siva83
5 Replies
8. UNIX for Dummies Questions & Answers
URGENT HELP IS NEEDED!!
I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but
- Currently, script is not printing lines to File3.txt in order.
- Also the matching lines are not moving out of File1.txt
... (1 Reply)
Discussion started by: High-T
1 Replies
9. Shell Programming and Scripting
Hello,
I have a file contains two columns. I need to print the lines after “xxx” so i'm trying to match "xxx" & cut the lines after that. I'm trying with the grep & cut command, if there any simple way to extract this please help me.
Sample file :
name id
AAA 123
AAB 124
AAC 125... (4 Replies)
Discussion started by: Shenbaga.d
4 Replies
10. Shell Programming and Scripting
Hello,
one step in a shell script i am writing, involves Grep command to search a regular expression in a line an only print the string after the match
an example line is below
/logs/GRAS/LGT/applogs/lgt-2016-08-24/2016-08-24.8.log.zip:2016-08-24 19:12:48,602 ERROR... (9 Replies)
Discussion started by: Ramneekgupta91
9 Replies
LN(1) FSF LN(1)
NAME
ln - make links between files
SYNOPSIS
ln [OPTION]... TARGET [LINK_NAME]
ln [OPTION]... TARGET... DIRECTORY
ln [OPTION]... --target-directory=DIRECTORY TARGET...
DESCRIPTION
Create a link to the specified TARGET with optional LINK_NAME. If LINK_NAME is omitted, a link with the same basename as the TARGET is
created in the current directory. When using the second form with more than one TARGET, the last argument must be a directory; create
links in DIRECTORY to each TARGET. Create hard links by default, symbolic links with --symbolic. When creating hard links, each TARGET
must exist.
Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL]
make a backup of each existing destination file
-b like --backup but does not accept an argument
-d, -F, --directory
hard link directories (super-user only)
-f, --force
remove existing destination files
-n, --no-dereference
treat destination that is a symlink to a directory as if it were a normal file
-i, --interactive
prompt whether to remove destinations
-s, --symbolic
make symbolic links instead of hard links
-S, --suffix=SUFFIX
override the usual backup suffix
--target-directory=DIRECTORY
specify the DIRECTORY in which to create the links
-v, --verbose
print name of each file before linking
--help display this help and exit
--version
output version information and exit
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup
option or through the VERSION_CONTROL environment variable. Here are the values:
none, off
never make backups (even if --backup is given)
numbered, t
make numbered backups
existing, nil
numbered if numbered backups exist, simple otherwise
simple, never
always make simple backups
AUTHOR
Written by Mike Parker and David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
SEE ALSO
The full documentation for ln is maintained as a Texinfo manual. If the info and ln programs are properly installed at your site, the com-
mand
info ln
should give you access to the complete manual.
ln (coreutils) 4.5.3 February 2003 LN(1)