HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Best scripting instrument ?
Operating System - HP-UX
1833777
Members
2153
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
10-08-2003 01:26 AM
10-08-2003 01:26 AM
Hi all,
I need to do something simple: from a series of data text files with columns divided by one or more blanks, I need first to count the number of columns (fields), and the print out on stdout the first 6 columns, then the last 31, and then the rest of the columns.
I am obviously in a hurry, and I am facing some problems with a short C program that uses strtok, strcat etc.
Has anyone a better idea than using C ?
Thank you
Enrico
I need to do something simple: from a series of data text files with columns divided by one or more blanks, I need first to count the number of columns (fields), and the print out on stdout the first 6 columns, then the last 31, and then the rest of the columns.
I am obviously in a hurry, and I am facing some problems with a short C program that uses strtok, strcat etc.
Has anyone a better idea than using C ?
Thank you
Enrico
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 01:36 AM
10-08-2003 01:36 AM
Re: Best scripting instrument ?
Enrico,
Everyone will have a different view on this but "perl" is going to be heaven for this kind of thing. It is remarkably good and string and data handling. I hardly ever use 'C' these days, it's just so much better to do the thing with perl.
Everyone will have a different view on this but "perl" is going to be heaven for this kind of thing. It is remarkably good and string and data handling. I hardly ever use 'C' these days, it's just so much better to do the thing with perl.
Never preceed any demonstration with anything more predictive than "watch this"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 01:41 AM
10-08-2003 01:41 AM
Solution
If the length of the input records does not exceed 3000 characters then awk is probably your quickest to learn method.
Try this, create a file, my.awk:
{
n = split($0,arry)
i = 1; # awk arrays are 1-based
while (i <= 6)
{
printf("%s ",arry[i])
++i
}
i = n - 31;
while (i <= n)
{
printf("%s ",arry[i]);
++i;
}
i = 7;
while (i < (n - 31))
{
printf("%s ",arry[i]);
++i;
}
printf("\n");
}
now awk -f my.awk < infile
If the input lines exceed 3,000 characters then get the Gnu version of awk. My real favorite -- although the learning curve is steeper but worth it -- is Perl. Well. written Perl will execute almost as faat as the C equivalent and code in a fraction of the time --- and port unchanged to Windows.
Try this, create a file, my.awk:
{
n = split($0,arry)
i = 1; # awk arrays are 1-based
while (i <= 6)
{
printf("%s ",arry[i])
++i
}
i = n - 31;
while (i <= n)
{
printf("%s ",arry[i]);
++i;
}
i = 7;
while (i < (n - 31))
{
printf("%s ",arry[i]);
++i;
}
printf("\n");
}
now awk -f my.awk < infile
If the input lines exceed 3,000 characters then get the Gnu version of awk. My real favorite -- although the learning curve is steeper but worth it -- is Perl. Well. written Perl will execute almost as faat as the C equivalent and code in a fraction of the time --- and port unchanged to Windows.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2003 02:09 AM
10-08-2003 02:09 AM
Re: Best scripting instrument ?
Thank you all for the prompt reply. The awk solution worked for me.
I should begin to study Perl in the near future ..
Thank you again
Enrico
I should begin to study Perl in the near future ..
Thank you again
Enrico
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP