- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- need help on getting data in 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
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
тАО04-19-2006 01:39 AM
тАО04-19-2006 01:39 AM
i have this script:
user=`whoami`
elist=`whoami`@mydomain.com
date_str=`date "+%m/%d/%y%H%M%S"`
subject="PDF file"
set -x
cat "$1" |tr -d `echo "\015"` > "$1""pdf"
echo "$2" "$1" "$3"
/baan4/c4/bse/starjet/starpage -s"$3" -c"$2" -d/tmp/$user.pdf -m:pdf "$1""pdf"
uuencode /tmp/$user.pdf $user$date_str.pdf | mailx -m -s "$subject" $elist
where user will get by email a pdf file named with this format mylogindatetime.pdf
script is working ok but here is the catch. I need to fetch invoice number stored in "$1""pdf" and use it has a the name of the file instead of the login date and time.
if i do a "grep Invoice" of the file i get:
"customer name Invoice N: 12345 SLS"
how can i fetch the 12345 SLS and put it in a variable so i can use it in the script?
I'm no expert on scripting so any help will be appreciated.
Regards
PB
Solved! Go to Solution.
- Tags:
- uuencode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2006 01:51 AM
тАО04-19-2006 01:51 AM
Re: need help on getting data in a file
The use of a simple 'cut' will extract the fields you want:
# X="customer name Invoice N: 12345 SLS"
# Y=`echo ${X}|cut -d" " -f 5-6`
# echo ${Y}
12345 SLS
Regards!
...JRF...
- Tags:
- cut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2006 01:54 AM
тАО04-19-2006 01:54 AM
Re: need help on getting data in a file
This is clearer, perhaps:
# VAR=`grep "Invoice" file|cut -d " " -f 5-6`
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2006 02:35 AM
тАО04-19-2006 02:35 AM
Solutionif the requested items are the last part of this line:
awk '/ Invoice / {print ($(NF-1),$NF);exit}' "$1"pdf | read num str
and use $num and $str for these values.
mfG Peter
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2006 03:30 AM
тАО04-19-2006 03:30 AM
Re: need help on getting data in a file
thanks for your help on this. Both info were good.
Regards
PB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-19-2006 08:19 PM
тАО04-19-2006 08:19 PM
Re: need help on getting data in a file
grep Invoice f3|tr -d '"'|cut -d" " -f5,6|read x y
It runs on my HPUx11i:
/tmp/>cat f3
"customer name Invoice N: 12345 SLS"
/tmp/>grep Invoice f3|tr -d '"'|cut -d" " -f5,6|read x y
/tmp/>echo $x
12345
/tmp/>echo $y
SLS
HTH,
Art