- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to suppress printing of a file with a particul...
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
03-01-2001 05:34 PM
03-01-2001 05:34 PM
How to suppress printing of a file with a particular pattern?
I have a bunch of files which I want to use a shell script to filter out for billing. Only those files with line 79 (fixed line number) having the string 'John' will not be sent to the printer for billing. How can I use a combination of awk and other shell functions to do it?
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2001 06:40 PM
03-01-2001 06:40 PM
Re: How to suppress printing of a file with a particular pattern?
for FILE in `ls /dir/dir/files`; do
PRINT=`cat $FILE |head -n 79 |tail -n 1|grep John`
if [ "X$PRINT" = "XJohn" ]; then
lp -d myprinter $FILE
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2001 06:41 PM
03-01-2001 06:41 PM
Re: How to suppress printing of a file with a particular pattern?
Here is a simple script that should do what you want. It will process each file in the current directory. You may replace the * with a file list if you want.
for filename in *
do
if head -79 $filename | tail -1 | grep -q John
then
: # do nothing
else
lp $filename
fi
done
The -q option to grep will suppress grep's stdout.
--Bruce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2001 11:43 PM
03-01-2001 11:43 PM
Re: How to suppress printing of a file with a particular pattern?
just another idea:
for file in *
do
awk 'NR==79 && /John/{exit 1}' $file && lp $file
done
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2001 09:00 PM
03-02-2001 09:00 PM
Re: How to suppress printing of a file with a particular pattern?
Please use dos2ux command to convert dos file to unix file
#dos2ux dosfile > unixfile
Thanks