- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 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
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 12:33 AM
04-19-2004 12:33 AM
awk Help
I have one file with 3 columns, i want to take the content of this file in a individual file based on substr(3,1,3) field.
B---A213---206934875
B---A213---20534875
B---A213---207934875
.....
.....
Space is indicated by "---"
i want three output files as below,
File F206==> B---A213---206934875
File F205==> B---A213---20534875
File F207==> B---A213---207934875
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 12:41 AM
04-19-2004 12:41 AM
Re: awk Help
IFS="
"
for i in `cat datafile`
do
newfile=`expr "$i" : ".......\(...\)"`
echo "$i" > "F$newfile"
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 12:48 AM
04-19-2004 12:48 AM
Re: awk Help
Based on
B A213 206934875
B A213 20534875
B A213 207934875
in tmp/fil
cat tmp/fil|while read line
do
echo $line|read a b c
name="F"$(echo $c|cut -c1-3)
echo "$line" > $name
done
Based on
B---A213---206934875
B---A213---20534875
B---A213---207934875
cat tmp/fil|while read line
do
name="F"$(echo $line|cut -c12-14)
echo "$line" > $name
done
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 12:53 AM
04-19-2004 12:53 AM
Re: awk Help
Assuming the text in file "s.txt"
Run
awk '{print "echo " $0 " >> F" substr($0,12,3) }' s.txt > foo.sh
This will generate foo.sh
Just run foo.sh will give you the result.
Enjoy.
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 12:55 AM
04-19-2004 12:55 AM
Re: awk Help
Thanks for quick reply. shall we do it using "AWK"
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 01:13 AM
04-19-2004 01:13 AM
Re: awk Help
The awk solution posted above does not give you the additional files you wanted by the way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 01:33 AM
04-19-2004 01:33 AM
Re: awk Help
Seems a little over the top to use awk to create a shell script when you can do it in a shell script to start with, however, 10 points for style on that one Kartik :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2004 01:53 AM
04-19-2004 01:53 AM
Re: awk Help
awk '{print $0 >"F" substr($3,1,3)}'
HTH
-- Rod Hills