Bash â reversing MD5 output in a text file & sorting
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I have a file1.txt with a list of MD5sums and corresponding filenames.
edad74614d6d3fa2252c3d74ff037ac7 wp-blog-header.php
de4edc0df80ba147ebcc26f9e0a8b96f wp-config.php
68070de41736e57f8757648a80b9cbbb wp-admin/upgrade-functions.php
29b6a5c82153f1371e1188ffa7b47619 wp-admin/error_log
55373449cc2320c57803f1f5b52b9ce9 wp-admin/edit.php
How do I dump this to a file2.txt with lines starting with the filenames instead of the hash and sort alphabetically like such:
wp-blog-header.php edad74614d6d3fa2252c3d74ff037ac7
wp-config.php de4edc0df80ba147ebcc26f9e0a8b96f
wp-admin/edit.php 55373449cc2320c57803f1f5b52b9ce9
wp-admin/error_log 29b6a5c82153f1371e1188ffa7b47619
wp-admin/upgrade-functions.php 68070de41736e57f8757648a80b9cbbb
Thank you so, so much!
command-line text-processing
 |Â
show 1 more comment
up vote
1
down vote
favorite
I have a file1.txt with a list of MD5sums and corresponding filenames.
edad74614d6d3fa2252c3d74ff037ac7 wp-blog-header.php
de4edc0df80ba147ebcc26f9e0a8b96f wp-config.php
68070de41736e57f8757648a80b9cbbb wp-admin/upgrade-functions.php
29b6a5c82153f1371e1188ffa7b47619 wp-admin/error_log
55373449cc2320c57803f1f5b52b9ce9 wp-admin/edit.php
How do I dump this to a file2.txt with lines starting with the filenames instead of the hash and sort alphabetically like such:
wp-blog-header.php edad74614d6d3fa2252c3d74ff037ac7
wp-config.php de4edc0df80ba147ebcc26f9e0a8b96f
wp-admin/edit.php 55373449cc2320c57803f1f5b52b9ce9
wp-admin/error_log 29b6a5c82153f1371e1188ffa7b47619
wp-admin/upgrade-functions.php 68070de41736e57f8757648a80b9cbbb
Thank you so, so much!
command-line text-processing
Sorry about that. Fixed.
â user9331490
Feb 9 at 6:42
Thanks. So you want to sort only on filenames and not on the whole path? Whole path is easier. Do the paths contain spaces? Is something likewp-admin/foo bar.php
possible?
â muru
Feb 9 at 6:43
The reason of the sorting is so that I can then compare the file2.txt with a file3.txt for non-matching lines for "file change detection". I figure this is more efficient with alphabetical sorting. It's better to have space tolerable code just in case.
â user9331490
Feb 9 at 6:52
More efficient than alphabetical sorting? But it looks like you want the filenames alphabetically sorted (or lexicographically sorted, rather)
â muru
Feb 9 at 7:10
2
I guess it's better you would post the activity you were going to do compare for file change with X-->Y way instead of going into X-->X1-->Y way.
â Ã±ÃÂsýù÷
Feb 9 at 7:11
 |Â
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a file1.txt with a list of MD5sums and corresponding filenames.
edad74614d6d3fa2252c3d74ff037ac7 wp-blog-header.php
de4edc0df80ba147ebcc26f9e0a8b96f wp-config.php
68070de41736e57f8757648a80b9cbbb wp-admin/upgrade-functions.php
29b6a5c82153f1371e1188ffa7b47619 wp-admin/error_log
55373449cc2320c57803f1f5b52b9ce9 wp-admin/edit.php
How do I dump this to a file2.txt with lines starting with the filenames instead of the hash and sort alphabetically like such:
wp-blog-header.php edad74614d6d3fa2252c3d74ff037ac7
wp-config.php de4edc0df80ba147ebcc26f9e0a8b96f
wp-admin/edit.php 55373449cc2320c57803f1f5b52b9ce9
wp-admin/error_log 29b6a5c82153f1371e1188ffa7b47619
wp-admin/upgrade-functions.php 68070de41736e57f8757648a80b9cbbb
Thank you so, so much!
command-line text-processing
I have a file1.txt with a list of MD5sums and corresponding filenames.
edad74614d6d3fa2252c3d74ff037ac7 wp-blog-header.php
de4edc0df80ba147ebcc26f9e0a8b96f wp-config.php
68070de41736e57f8757648a80b9cbbb wp-admin/upgrade-functions.php
29b6a5c82153f1371e1188ffa7b47619 wp-admin/error_log
55373449cc2320c57803f1f5b52b9ce9 wp-admin/edit.php
How do I dump this to a file2.txt with lines starting with the filenames instead of the hash and sort alphabetically like such:
wp-blog-header.php edad74614d6d3fa2252c3d74ff037ac7
wp-config.php de4edc0df80ba147ebcc26f9e0a8b96f
wp-admin/edit.php 55373449cc2320c57803f1f5b52b9ce9
wp-admin/error_log 29b6a5c82153f1371e1188ffa7b47619
wp-admin/upgrade-functions.php 68070de41736e57f8757648a80b9cbbb
Thank you so, so much!
command-line text-processing
command-line text-processing
edited Feb 9 at 6:42
asked Feb 9 at 6:35
user9331490
122
122
Sorry about that. Fixed.
â user9331490
Feb 9 at 6:42
Thanks. So you want to sort only on filenames and not on the whole path? Whole path is easier. Do the paths contain spaces? Is something likewp-admin/foo bar.php
possible?
â muru
Feb 9 at 6:43
The reason of the sorting is so that I can then compare the file2.txt with a file3.txt for non-matching lines for "file change detection". I figure this is more efficient with alphabetical sorting. It's better to have space tolerable code just in case.
â user9331490
Feb 9 at 6:52
More efficient than alphabetical sorting? But it looks like you want the filenames alphabetically sorted (or lexicographically sorted, rather)
â muru
Feb 9 at 7:10
2
I guess it's better you would post the activity you were going to do compare for file change with X-->Y way instead of going into X-->X1-->Y way.
â Ã±ÃÂsýù÷
Feb 9 at 7:11
 |Â
show 1 more comment
Sorry about that. Fixed.
â user9331490
Feb 9 at 6:42
Thanks. So you want to sort only on filenames and not on the whole path? Whole path is easier. Do the paths contain spaces? Is something likewp-admin/foo bar.php
possible?
â muru
Feb 9 at 6:43
The reason of the sorting is so that I can then compare the file2.txt with a file3.txt for non-matching lines for "file change detection". I figure this is more efficient with alphabetical sorting. It's better to have space tolerable code just in case.
â user9331490
Feb 9 at 6:52
More efficient than alphabetical sorting? But it looks like you want the filenames alphabetically sorted (or lexicographically sorted, rather)
â muru
Feb 9 at 7:10
2
I guess it's better you would post the activity you were going to do compare for file change with X-->Y way instead of going into X-->X1-->Y way.
â Ã±ÃÂsýù÷
Feb 9 at 7:11
Sorry about that. Fixed.
â user9331490
Feb 9 at 6:42
Sorry about that. Fixed.
â user9331490
Feb 9 at 6:42
Thanks. So you want to sort only on filenames and not on the whole path? Whole path is easier. Do the paths contain spaces? Is something like
wp-admin/foo bar.php
possible?â muru
Feb 9 at 6:43
Thanks. So you want to sort only on filenames and not on the whole path? Whole path is easier. Do the paths contain spaces? Is something like
wp-admin/foo bar.php
possible?â muru
Feb 9 at 6:43
The reason of the sorting is so that I can then compare the file2.txt with a file3.txt for non-matching lines for "file change detection". I figure this is more efficient with alphabetical sorting. It's better to have space tolerable code just in case.
â user9331490
Feb 9 at 6:52
The reason of the sorting is so that I can then compare the file2.txt with a file3.txt for non-matching lines for "file change detection". I figure this is more efficient with alphabetical sorting. It's better to have space tolerable code just in case.
â user9331490
Feb 9 at 6:52
More efficient than alphabetical sorting? But it looks like you want the filenames alphabetically sorted (or lexicographically sorted, rather)
â muru
Feb 9 at 7:10
More efficient than alphabetical sorting? But it looks like you want the filenames alphabetically sorted (or lexicographically sorted, rather)
â muru
Feb 9 at 7:10
2
2
I guess it's better you would post the activity you were going to do compare for file change with X-->Y way instead of going into X-->X1-->Y way.
â Ã±ÃÂsýù÷
Feb 9 at 7:11
I guess it's better you would post the activity you were going to do compare for file change with X-->Y way instead of going into X-->X1-->Y way.
â Ã±ÃÂsýù÷
Feb 9 at 7:11
 |Â
show 1 more comment
2 Answers
2
active
oldest
votes
up vote
3
down vote
If your aim is to sort a text file based on specific columns you don't need to change the column order if you use the -k
option of GNU sort
. To only sort based on the 2nd and subsequent (white-space delimited) columns use:
sort -k 2
Additionally I advise you to use the C
or POSIX
collation locale to compare and sort path names or you may receive unexpected results due to case-insensitivity or special characters:
LC_COLLATE=POSIX sort ...
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
add a comment |Â
up vote
1
down vote
How about:
awk ' print $2, $1 ' < file | sort > file2
This will take the data from the file called 'file', swap the two fields and sort them into file 'file2'
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
If your aim is to sort a text file based on specific columns you don't need to change the column order if you use the -k
option of GNU sort
. To only sort based on the 2nd and subsequent (white-space delimited) columns use:
sort -k 2
Additionally I advise you to use the C
or POSIX
collation locale to compare and sort path names or you may receive unexpected results due to case-insensitivity or special characters:
LC_COLLATE=POSIX sort ...
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
add a comment |Â
up vote
3
down vote
If your aim is to sort a text file based on specific columns you don't need to change the column order if you use the -k
option of GNU sort
. To only sort based on the 2nd and subsequent (white-space delimited) columns use:
sort -k 2
Additionally I advise you to use the C
or POSIX
collation locale to compare and sort path names or you may receive unexpected results due to case-insensitivity or special characters:
LC_COLLATE=POSIX sort ...
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
add a comment |Â
up vote
3
down vote
up vote
3
down vote
If your aim is to sort a text file based on specific columns you don't need to change the column order if you use the -k
option of GNU sort
. To only sort based on the 2nd and subsequent (white-space delimited) columns use:
sort -k 2
Additionally I advise you to use the C
or POSIX
collation locale to compare and sort path names or you may receive unexpected results due to case-insensitivity or special characters:
LC_COLLATE=POSIX sort ...
If your aim is to sort a text file based on specific columns you don't need to change the column order if you use the -k
option of GNU sort
. To only sort based on the 2nd and subsequent (white-space delimited) columns use:
sort -k 2
Additionally I advise you to use the C
or POSIX
collation locale to compare and sort path names or you may receive unexpected results due to case-insensitivity or special characters:
LC_COLLATE=POSIX sort ...
answered Feb 9 at 18:17
![](https://i.stack.imgur.com/E0SEH.png?s=32&g=1)
![](https://i.stack.imgur.com/E0SEH.png?s=32&g=1)
David Foerster
26.5k1362106
26.5k1362106
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
add a comment |Â
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
As youâÂÂve never accepted an answer before: if this answers your question, donâÂÂt forget to click the grey â under the number at the left of this text to accept it, which means âÂÂyes, this answer is validâÂÂ!
â David Foerster
Feb 9 at 18:19
add a comment |Â
up vote
1
down vote
How about:
awk ' print $2, $1 ' < file | sort > file2
This will take the data from the file called 'file', swap the two fields and sort them into file 'file2'
add a comment |Â
up vote
1
down vote
How about:
awk ' print $2, $1 ' < file | sort > file2
This will take the data from the file called 'file', swap the two fields and sort them into file 'file2'
add a comment |Â
up vote
1
down vote
up vote
1
down vote
How about:
awk ' print $2, $1 ' < file | sort > file2
This will take the data from the file called 'file', swap the two fields and sort them into file 'file2'
How about:
awk ' print $2, $1 ' < file | sort > file2
This will take the data from the file called 'file', swap the two fields and sort them into file 'file2'
answered Feb 9 at 19:13
![](https://i.stack.imgur.com/k5SI6.jpg?s=32&g=1)
![](https://i.stack.imgur.com/k5SI6.jpg?s=32&g=1)
Colin Ian King
11.6k13346
11.6k13346
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1004468%2fbash-reversing-md5-output-in-a-text-file-sorting%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sorry about that. Fixed.
â user9331490
Feb 9 at 6:42
Thanks. So you want to sort only on filenames and not on the whole path? Whole path is easier. Do the paths contain spaces? Is something like
wp-admin/foo bar.php
possible?â muru
Feb 9 at 6:43
The reason of the sorting is so that I can then compare the file2.txt with a file3.txt for non-matching lines for "file change detection". I figure this is more efficient with alphabetical sorting. It's better to have space tolerable code just in case.
â user9331490
Feb 9 at 6:52
More efficient than alphabetical sorting? But it looks like you want the filenames alphabetically sorted (or lexicographically sorted, rather)
â muru
Feb 9 at 7:10
2
I guess it's better you would post the activity you were going to do compare for file change with X-->Y way instead of going into X-->X1-->Y way.
â Ã±ÃÂsýù÷
Feb 9 at 7:11