- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how to get a CRC or a quick hash of a single l...
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
тАО12-19-2007 09:55 AM
тАО12-19-2007 09:55 AM
I've never tried to get one before - short of writing one in C oh so many moons ago, but I figure that there's gotta be some out there already. Anyone can give me some advice on this?
Thanks!
Solved! Go to Solution.
- Tags:
- CRC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 10:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 10:13 AM
тАО12-19-2007 10:13 AM
Re: how to get a CRC or a quick hash of a single line of text?
# echo "this is a line of text"|cksum
2829970435
# echo "this is a line of text"|md5sum
edb95cc51670abff69d0af7fa1c8122b
# echo "this is a line of text"|sum -r|cut -f1 -d" "
23527
See the manpages for 'sum(1)' in particular too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 10:44 AM
тАО12-19-2007 10:44 AM
Re: how to get a CRC or a quick hash of a single line of text?
/* NO POINTS PLEASE */
Sorry for the double post. I got an error posting and decided my reply had hit the black hole. Hence, I added a closing thought and submitted again.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 11:19 AM
тАО12-19-2007 11:19 AM
Re: how to get a CRC or a quick hash of a single line of text?
# awk '{printf("%-15d\n", rand(srand(NR))*(10^9))}' file
~cheers
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 12:14 PM
тАО12-19-2007 12:14 PM
Re: how to get a CRC or a quick hash of a single line of text?
That's exactly what I needed.
Much appreciated,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 12:21 PM
тАО12-19-2007 12:21 PM
Re: how to get a CRC or a quick hash of a single line of text?
So, you get 10 points for being there like I've been there, because I thought I was the only one who had posts that look like that. Yeah, I know you asked for no points, but since it is my thread and I get to decide, I decided to push 10 points on empathy.
:-) Nygeah :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 12:33 PM
тАО12-19-2007 12:33 PM
Re: how to get a CRC or a quick hash of a single line of text?
Thanks for the nice awk script. Can I ask you how to add a few more things to that? I was going to shell script all of this, but since you've nailed down a piece of it in awk, I wonder if you'd mind helping me a bit more?
Give me a) line number, b) CRC type sum code, and c) the text itself. Separated by "^" symbol.
I hate to ask, but if you're strong on awk, it would get me rolling pretty quickly on my little project.
I think it would resemble:
awk '{printf("%d^%-15d^$*\n",somelinecountervariable rand(srand(NR))*(10^9))}' /tmp/junk
The problem that I'd have is identifying the linecounter variable. I'm assuming there's a builtin in awk for this, instead of having to count with a loop??? Also, I'm supposing tha t$* prints the contents of the line, or would I use the (NR) maybe?
Thanks if you can help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 02:52 PM
тАО12-19-2007 02:52 PM
Re: how to get a CRC or a quick hash of a single line of text?
NR stands for the line (aka record) number and $0 stands for the entire line.
# awk '{printf("%d^%-13d^%s\n", NR, rand(srand(NR))*(10^9), $0)}' file
~hope it helps