- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Optimizing 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
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-06-2006 06:30 PM
03-06-2006 06:30 PM
I had this file generated by a script.
The script prompt user to enter the start index then it paste the index in the file.
Lets say file abc has contents
wqer
asdf
zxcv
then I ran the script: enter first index : read index then example index = 1.
then it outputs the file
wqer 1
asdf 2
zxcv 3 if index = 4 then it ouputs file
qwer 4
asdf 5
zxcv 6
Is there a way where I can fasten it up like awk? i just did a loop script but it is slow for 60K rows (would take 20mins)
thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2006 06:34 PM
03-06-2006 06:34 PM
Re: Optimizing script
It would be helpful if you attached your script. I am sure it could be sped up with a number of methods, but to optimize a script, I need to see the script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2006 06:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2006 07:30 PM
03-06-2006 07:30 PM
Re: Optimizing script
Jean-Yves solution with awk runs in less than 1 second on my machine (L1000-44)!
You are redirecting the output ?
read index
awk -v s=$index '{print $0 " " s ; s++}' $myfile > $myfile.new
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2006 07:35 PM
03-06-2006 07:35 PM
Re: Optimizing script
You can improve by providing the index value in the awk statement instead of reading as a value.
Just like here.
cat abc | awk '{print $1 " " a+1;a++}'
if your index =1
IA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 05:44 PM
03-07-2006 05:44 PM
Re: Optimizing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 08:43 PM
03-07-2006 08:43 PM
Re: Optimizing script
read index?"start index: "
awk 'BEGIN {start_index='''$index'''};{print $0 " " start_index++}'
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 11:29 PM
03-07-2006 11:29 PM
Re: Optimizing script
I somewhat do not get what you want to do with that file? You use index=1 and then index=4?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2006 11:57 PM
03-07-2006 11:57 PM
Re: Optimizing script
As mentioned, in the absence of a sample of what you want to achieve, it is difficult to provide optimizations.
What language or languages do you want to use --- Shell, awk, Perl ?
If you are using a shell, 'typeset' to integer for faster arithmetic at the least.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2006 12:45 AM
03-08-2006 12:45 AM
Re: Optimizing script
This appears to be a continutation of topic:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1006890
Ferdi,
Please help us understand why the awk solutions where not deemed acceptable. Maybe we can address that.
And if the conslusion is that only a shell script is acceptable, then why not show us what you have now. Maybe someone will sport a critical problem with it.
But I believe we can only add value once we understand why the simple awk (or perl or whatever) solution was not accpetable.
In the mean time, here is a silly sh script which would not take 20 minutes for 60k lines:
# cat > x
wqer
asdf
zxcv
# export index=123
# ./x.sh < x
wqer 124
asdf 125
zxcv 126
# export index=4
# ./x.sh < x
wqer 5
asdf 6
zxcv 7
# cat x.sh
#!/bin/sh
while read line
do
let "index += 1"
echo "$line $index"
done
hth,
Hein.