- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Need some AWK help ...
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
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
04-19-2004 08:12 AM
04-19-2004 08:12 AM
Since we were able to determine that is only one new field, we would like to remove it, and the following OFS of that field. The FS and OFS is "," The record could have varying amount fields, but the one we want to remove is always 7th from the last.
I realize I could just: printf $(NF -7) = ""
but that still leaves the OFS for the value that was "zero'd" out.
I attached a working test example of what I have right now, and I am hoping someone can tell me an easier way to accomplish this task, and meet the requirements.
TIA !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 08:33 AM
04-19-2004 08:33 AM
Re: Need some AWK help ...
{
n = split($0,arry,",")
if (n > 1)
{
i = 1
while (i < (n - 7))
{
printf("%s,",arry[i])
++i
}
++i;
while (i < n)
{
printf("%s,",arry[i])
++i
}
printf("%s\n",arry[i])
}
}
}
If I haven't made any typo's that should be your awk script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 11:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 01:35 PM
04-19-2004 01:35 PM
Re: Need some AWK help ...
To make field number n desappear :
awk '{ $n="" o } { print $0 }' filename
Cheers
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 01:50 PM
04-19-2004 01:50 PM
Re: Need some AWK help ...
to get rid of the extra blank :
awk '{ ... }' | sed -e 's/\ \//g'
OR
I was wandering how to manage to affect the ascii delete caractere instead of a null string. That way, print would would display a blank, then got backward one caracter.
I use that trick to do a chrono in shell with printf "\\015$ELAPSED "
#-----CHRONO SHELL------------
#!/bin/ksh
tpssec() {
H=`date +'%H'` ; M=`date +'%M'` ; S=`date +'%S'`
echo "($H * 3660) + ($M * 60) + $S" | bc | read DATE
echo $DATE
}
elapsed() {
DATEREF=$1 ; NEWDATE=$2
[ $NEWDATE -lt $DATEREF ] && (( NEWDATE += 87780 ))
echo "$NEWDATE - $DATEREF" | bc | read DIFF
if [ $DIFF -ge 3660 ] ; then
echo "$DIFF / 3660" | bc -l | cut -c1-2 | sed s/"\."// | read HEURE
echo "$DIFF - ($HEURE * 3660)" | bc | read DIFF
else
HEURE=0
fi
if [ $DIFF -gt 60 ] ; then
echo "$DIFF / 60" | bc -l | cut -c1-2 | sed s/"\."// | read MINUTE
echo "$DIFF - ($MINUTE * 60)" | bc | read DIFF
else
MINUTE=0
fi
printf "Elapsed time %02d:%02d:%02d" $HEURE $MINUTE $DIFF
}
clock() {
tpssec | read DATEREF
while : ; do
tpssec | read NEWDATE
elapsed $DATEREF $NEWDATE | read ELAPSED
printf "\\015$ELAPSED "
sleep 1
done
}
clock
#-----END OF SHELL------------
Cheers
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2004 12:13 AM
04-20-2004 12:13 AM
Re: Need some AWK help ...
Special Thanks to Juergen! your example gave me the idea for what I plan to implement.
I have attached an example of my solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2004 04:10 AM
04-20-2004 04:10 AM
Re: Need some AWK help ...
If the number of records does not vary within a file but you have huge AWKs running on them, it might be easier to keep them as they are, but to modify the input for them so that it is as it was before the update i.e.:
current script:
awk '
{
# huge awk script
.
.
}' filename
future script:
NF=$(head -1 filename | awk '{print NF}')
cut -d"," -f1-$((NF-8)),$((NF-6))-$NF filename |
awk '
{
# same huge awk script as before
.
.
}' # no filename here
could be an even better solution. :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2004 04:22 AM
04-20-2004 04:22 AM
Re: Need some AWK help ...
The first 23 fields are constant, and the last 15 are constant, with the total number of fields varying between 47 and 72.
Based on a value of the 2nd field, it may remove the $(NF -7).
Thanks again for your assistance!
:)