- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Stripping certain lines from a file
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
Forums
Discussions
Discussions
Discussions
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
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
08-24-2000 06:39 AM
08-24-2000 06:39 AM
I have a requirement to select from a file all lines following the first line with the numbers 0 and 8 in positions 61 and 62 respectively.
I have tried some sed functions
sed -n '.{60}08' filename
without success.
Any suggestions
Dave
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 06:52 AM
08-24-2000 06:52 AM
Re: Stripping certain lines from a file
Hope this helps,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 06:57 AM
08-24-2000 06:57 AM
Re: Stripping certain lines from a file
cat /tmp/in|cut -c61-62|grep "08" > /tmp/out
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 06:59 AM
08-24-2000 06:59 AM
Re: Stripping certain lines from a file
grep '^.{60}08' filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:05 AM
08-24-2000 07:05 AM
Re: Stripping certain lines from a file
try this command:
awk '{if (substr($0,60,2)=="08") print }' name_of_your_file
regards
Jaroslaw
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:14 AM
08-24-2000 07:14 AM
Re: Stripping certain lines from a file
awk '{if(NR>1){if(substr($0,61,2)=="08"){print $0}}}' input_file_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:24 AM
08-24-2000 07:24 AM
Re: Stripping certain lines from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:31 AM
08-24-2000 07:31 AM
Re: Stripping certain lines from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:36 AM
08-24-2000 07:36 AM
Re: Stripping certain lines from a file
awk '{if(substr($0,61,2)=="08"){flag=1}{if(flag==1){print $0}}}' input_file_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:48 AM
08-24-2000 07:48 AM
Re: Stripping certain lines from a file
b=wc -l filename
c=`expr b - a`
tail -$c filename
?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 07:55 AM
08-24-2000 07:55 AM
Re: Stripping certain lines from a file
let COUNT=0
for LINE in `cat gogo`
do
COUNT=`expr $COUNT + 1`
if [ "`echo $LINE|cut -c 61-62 | grep 08`" -eq 08 ]
then
TAIL=`expr $TOT - $COUNT `
tail -n`expr $TAIL` gogo>gugi
exit
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2000 11:17 PM
08-24-2000 11:17 PM
Solutiona=`grep -n '^.{60}08' filename | cut -d':' -f1|head -1`
b=`cat filename | wc -l`
c=`expr $b - $a`
tail -$c filename
Explanation:
in $a there is the number of the first coincident line
in $b the line number of the file
in $c the subtraction between the total number and first
Excuse by my English, is poor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2000 03:16 AM
08-25-2000 03:16 AM
Re: Stripping certain lines from a file
sed -n '/^.{60}08/,$p' filename
This gives sed the address-range from (first line with 08 in cols 61,62) to ($ meaning last line) to p (print)
Regards,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2000 03:23 AM
08-25-2000 03:23 AM
Re: Stripping certain lines from a file
The Backslashes before the two curly braces got eaten.
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:25 AM
08-28-2000 05:25 AM
Re: Stripping certain lines from a file
awk '{if(substr($0,61,2)=="08")
{while (getline){print $0}}
}' /tmp/abc > /tmp/xyz
Bye!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 05:26 AM
08-28-2000 05:26 AM
Re: Stripping certain lines from a file
awk '{if(substr($0,61,2)=="08")
{while (getline){print $0}}
}' /tmp/abc > /tmp/xyz
Bye!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2000 06:01 AM
08-28-2000 06:01 AM
Re: Stripping certain lines from a file
Thank you again.
Dave