- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:38 AM
тАО06-26-2003 05:38 AM
i have a file with block of approx 20 lines similar to the below, repeated 100's of times througout the file:
type: 114
id: 3
version: 3
date: 2003-06-25 10:30:55
node: 0
application: 0
length: 75345
class: 234
service: 0
content: 0
report: 0
timer: 0
count time: 0
input field: 0
The problem i that I need to output the line listed "class" and the line listed "date" together to a seperate file. I need this to be repeated from each block of 20 lines throughout the file. Any ideas?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:42 AM
тАО06-26-2003 05:42 AM
Re: Question about script
grep -e ^date: -e ^class: > /some/file
should do the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:43 AM
тАО06-26-2003 05:43 AM
Re: Question about script
grep -e ^date: -e ^class: /path/to/file > /some/file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:43 AM
тАО06-26-2003 05:43 AM
Re: Question about script
grep -e class -e date file > file.out
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:56 AM
тАО06-26-2003 05:56 AM
Re: Question about script
Use the grep command to do what you want. See from the man page:
grep, egrep, fgrep - search a file for a pattern
SYNOPSIS
Plain call with pattern
grep [-E|-F] [-c|-l|-q] [-bhinsvwx] pattern [file ...]
Call with (multiple) -e pattern
grep [-E|-F] [-c|-l|-q] [-bhinsvwx] -e pattern... [-e pattern] ...
[file ...]
Look at the line with the word multiple for details and re-direct to a new file like every other person mentioned (grep -e class -e date file > newfile) Check the man pages for more information.
Regards,
Dario
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 05:58 AM
тАО06-26-2003 05:58 AM
Re: Question about script
one final thing....
the resultant output is something like this..
.
.
.
.
class: 1234
date: 2003-6-26@08:01am
class: 0000
date: 2003-6-26@08:02am
class: 9999
date: 2003-6-26@08:03am
class: 0000
date: 2003-6-26@08:04am
class: 1234
date: 2003-6-26@08:05am
class: 0000
date: 2003-6-26@08:06am
.
.
From this file, I need to be able to list only the lines with class 0000 and their corresponding date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 06:02 AM
тАО06-26-2003 06:02 AM
Re: Question about script
awk '/class: 0000/{print ; getline ; print}' file
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 06:05 AM
тАО06-26-2003 06:05 AM
Re: Question about script
sed -n '/class: 0000/ {
N
p
}' file
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2003 06:06 AM
тАО06-26-2003 06:06 AM
Re: Question about script
Assume that you have the output in a file named output.txt. Below is a script to do what you want:
#!/bin/sh
while read CLASS
do
read DATE
if [ "$CLASS" = "class: 0000" ]
then
echo $CLASS
echo $DATE
fi
done < output.txt
Hai