Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So how do I use grep, to tell it to take the data before a space occurs, so that in both cases it'll only take the checksum value, and not the *KNOP.. or KNOP..?
It obviously isn't a critically important question, I'm just learning my way around the commands.. So just playing around to see what's possible.. Can anyone help?
Have you considered adding the aster to sum1 (given that you created that file) ?. Saves creating new files to diff, and the regex for (that) using sed will be much simpler.
That asterisk comes because md5sum has been run with the '-b argument. Since you already have the md5 checksum file, you can directly verify the iso file by running
Code:
md5sum -c KNO*md5
And it should give you something like KNOPPIX_V6.0.1CD-2009-02-08-EN.iso: OK
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441
Rep:
You can use cut command to get only the text you want from the files. However it will not solve your problem as diff only takes files as parameters (and STDIN by using "-" parameter).
Eg:
$ cut -d" " -f1 KNO*.md5
The above command will give you the output of d642d524dd2187834a418710001bbf82
What it does is, take the the first column (-f1) of the file (KNO*.md5) where column delimiter (-d) is a space (" "). The command could be alternatively written $ cut -d\ -f1 KNO*.md5 (notice the extra space after the "\")
If you want to do more stuff with this, better to look into awk too.
syg00! Yes, I know I can manually add the asterisk! hehehe.. I'm just learning to manipulate the commands in linux, so wanted to know if it's possible to get a perfect diff without changing it manually..
@arungoodboy
I didn't know md5sum would check it automatically.. Thanks! I thought I would always have to at least visibly compare checksums.. Makes life much easier.. Who says linux isn't user-friendly??
@SkyEye
Yes! That's exactly what I wanted! Thank you! And yes, you're right.. diff needs two file names as parameters.. thanks for pointing that out. Although I shall look into the 'cut' command. Looks very interesting.. I'm guessing in "cut -d\ -f1 KNO*.md5", the backslash is the escape character. I think 'grep' and 'cut' can work quite well with each other..
I started learning python mainly for scripting purposes, but I realised it's much more powerful than I thought.. I'll finish that first, but I'll definitely look into awk and sed...
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441
Rep:
@ShanxT, Yes the backslash is the escape character. And about sed and awk, it's be great to learn them. I never got to learn sed and awk much since when my scripting needs got complicated I switched to Ruby. I'm a happy camper as there's an awful lot of SysAdmin tools in Ruby (probably the best collection). Glad to know you are learning Python too.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.