Bash increment alphanumeric data from command prompt

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I need to increment alphanumeric data.



Increment numbers with seq is easy just: seq -w 0000001 9999999 >> file



But I need to increment alphanumeric data in order like this:



0000001
0000002
0000003
0000004
0000005
0000006
0000007
0000008
0000009
000000a
000000b
000000c
000000d
000000e
0000010
0000011
0000012
0000013
0000014
0000015
0000016
0000017
0000018
0000019
000001a
000001b
000001c
000001d
000001e
0000020
0000021


etc... until I hit eeeeeee



Using alphanumeric data 0-9a-e. Just need to load the data in an empty file and done. Is there an easy bash command for this something similar to the seq command? I'm using Linux Debian 6.3.0-18 and Bourne Again Shell.







share|improve this question






















  • These are numeric data in hex. They are not arbitrary alphanumeric data.
    – NickD
    Mar 24 at 3:44






  • 2




    I don't see any f in there: are you sure that it should not be there? That would be base 15 numeric data which seems ... strange.
    – NickD
    Mar 24 at 3:57















up vote
0
down vote

favorite












I need to increment alphanumeric data.



Increment numbers with seq is easy just: seq -w 0000001 9999999 >> file



But I need to increment alphanumeric data in order like this:



0000001
0000002
0000003
0000004
0000005
0000006
0000007
0000008
0000009
000000a
000000b
000000c
000000d
000000e
0000010
0000011
0000012
0000013
0000014
0000015
0000016
0000017
0000018
0000019
000001a
000001b
000001c
000001d
000001e
0000020
0000021


etc... until I hit eeeeeee



Using alphanumeric data 0-9a-e. Just need to load the data in an empty file and done. Is there an easy bash command for this something similar to the seq command? I'm using Linux Debian 6.3.0-18 and Bourne Again Shell.







share|improve this question






















  • These are numeric data in hex. They are not arbitrary alphanumeric data.
    – NickD
    Mar 24 at 3:44






  • 2




    I don't see any f in there: are you sure that it should not be there? That would be base 15 numeric data which seems ... strange.
    – NickD
    Mar 24 at 3:57













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I need to increment alphanumeric data.



Increment numbers with seq is easy just: seq -w 0000001 9999999 >> file



But I need to increment alphanumeric data in order like this:



0000001
0000002
0000003
0000004
0000005
0000006
0000007
0000008
0000009
000000a
000000b
000000c
000000d
000000e
0000010
0000011
0000012
0000013
0000014
0000015
0000016
0000017
0000018
0000019
000001a
000001b
000001c
000001d
000001e
0000020
0000021


etc... until I hit eeeeeee



Using alphanumeric data 0-9a-e. Just need to load the data in an empty file and done. Is there an easy bash command for this something similar to the seq command? I'm using Linux Debian 6.3.0-18 and Bourne Again Shell.







share|improve this question














I need to increment alphanumeric data.



Increment numbers with seq is easy just: seq -w 0000001 9999999 >> file



But I need to increment alphanumeric data in order like this:



0000001
0000002
0000003
0000004
0000005
0000006
0000007
0000008
0000009
000000a
000000b
000000c
000000d
000000e
0000010
0000011
0000012
0000013
0000014
0000015
0000016
0000017
0000018
0000019
000001a
000001b
000001c
000001d
000001e
0000020
0000021


etc... until I hit eeeeeee



Using alphanumeric data 0-9a-e. Just need to load the data in an empty file and done. Is there an easy bash command for this something similar to the seq command? I'm using Linux Debian 6.3.0-18 and Bourne Again Shell.









share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 3:55









Kevin

25.7k95797




25.7k95797










asked Mar 24 at 3:03









RainyDay

103




103











  • These are numeric data in hex. They are not arbitrary alphanumeric data.
    – NickD
    Mar 24 at 3:44






  • 2




    I don't see any f in there: are you sure that it should not be there? That would be base 15 numeric data which seems ... strange.
    – NickD
    Mar 24 at 3:57

















  • These are numeric data in hex. They are not arbitrary alphanumeric data.
    – NickD
    Mar 24 at 3:44






  • 2




    I don't see any f in there: are you sure that it should not be there? That would be base 15 numeric data which seems ... strange.
    – NickD
    Mar 24 at 3:57
















These are numeric data in hex. They are not arbitrary alphanumeric data.
– NickD
Mar 24 at 3:44




These are numeric data in hex. They are not arbitrary alphanumeric data.
– NickD
Mar 24 at 3:44




2




2




I don't see any f in there: are you sure that it should not be there? That would be base 15 numeric data which seems ... strange.
– NickD
Mar 24 at 3:57





I don't see any f in there: are you sure that it should not be there? That would be base 15 numeric data which seems ... strange.
– NickD
Mar 24 at 3:57











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Assuming you really mean hex (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) here is a solution up to FF (I don't want to have to count to 4.3 billion):



(echo obase=16; seq 1 $((echo ibase=16; echo FF) | bc)) | bc


The inner



(echo ibase=16; echo FF) | bc


calculates the ending value in decimal (here FF but feel free to substitute FFFFFFFF if you want :-). The seq then counts from one to 255 in this case, and the rest converts it to hex.



And if you really want base 15, you can change both 16's to 15's (and the FF... to EE...).






share|improve this answer




















  • This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
    – RainyDay
    Mar 24 at 6:57










  • You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
    – glenn jackman
    Mar 24 at 11:10


















up vote
1
down vote













Just play with the print operators



#!/bin/bash
for number in $( seq 1 255 )
do
hex_representation=$( printf "%X" $number )
echo "$number: $hex_representation"
done





share|improve this answer
















  • 2




    Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
    – steeldriver
    Mar 24 at 11:49










  • This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
    – RainyDay
    Mar 26 at 3:37










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433197%2fbash-increment-alphanumeric-data-from-command-prompt%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Assuming you really mean hex (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) here is a solution up to FF (I don't want to have to count to 4.3 billion):



(echo obase=16; seq 1 $((echo ibase=16; echo FF) | bc)) | bc


The inner



(echo ibase=16; echo FF) | bc


calculates the ending value in decimal (here FF but feel free to substitute FFFFFFFF if you want :-). The seq then counts from one to 255 in this case, and the rest converts it to hex.



And if you really want base 15, you can change both 16's to 15's (and the FF... to EE...).






share|improve this answer




















  • This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
    – RainyDay
    Mar 24 at 6:57










  • You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
    – glenn jackman
    Mar 24 at 11:10















up vote
1
down vote



accepted










Assuming you really mean hex (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) here is a solution up to FF (I don't want to have to count to 4.3 billion):



(echo obase=16; seq 1 $((echo ibase=16; echo FF) | bc)) | bc


The inner



(echo ibase=16; echo FF) | bc


calculates the ending value in decimal (here FF but feel free to substitute FFFFFFFF if you want :-). The seq then counts from one to 255 in this case, and the rest converts it to hex.



And if you really want base 15, you can change both 16's to 15's (and the FF... to EE...).






share|improve this answer




















  • This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
    – RainyDay
    Mar 24 at 6:57










  • You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
    – glenn jackman
    Mar 24 at 11:10













up vote
1
down vote



accepted







up vote
1
down vote



accepted






Assuming you really mean hex (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) here is a solution up to FF (I don't want to have to count to 4.3 billion):



(echo obase=16; seq 1 $((echo ibase=16; echo FF) | bc)) | bc


The inner



(echo ibase=16; echo FF) | bc


calculates the ending value in decimal (here FF but feel free to substitute FFFFFFFF if you want :-). The seq then counts from one to 255 in this case, and the rest converts it to hex.



And if you really want base 15, you can change both 16's to 15's (and the FF... to EE...).






share|improve this answer












Assuming you really mean hex (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) here is a solution up to FF (I don't want to have to count to 4.3 billion):



(echo obase=16; seq 1 $((echo ibase=16; echo FF) | bc)) | bc


The inner



(echo ibase=16; echo FF) | bc


calculates the ending value in decimal (here FF but feel free to substitute FFFFFFFF if you want :-). The seq then counts from one to 255 in this case, and the rest converts it to hex.



And if you really want base 15, you can change both 16's to 15's (and the FF... to EE...).







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 4:04









NickD

1,5571312




1,5571312











  • This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
    – RainyDay
    Mar 24 at 6:57










  • You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
    – glenn jackman
    Mar 24 at 11:10

















  • This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
    – RainyDay
    Mar 24 at 6:57










  • You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
    – glenn jackman
    Mar 24 at 11:10
















This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
– RainyDay
Mar 24 at 6:57




This is exactly what I was looking for. How can I make it start at 0000001 instead of 1?
– RainyDay
Mar 24 at 6:57












You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
– glenn jackman
Mar 24 at 11:10





You could pipe that command into | xargs printf "%7sn" | tr ' ' 0
– glenn jackman
Mar 24 at 11:10













up vote
1
down vote













Just play with the print operators



#!/bin/bash
for number in $( seq 1 255 )
do
hex_representation=$( printf "%X" $number )
echo "$number: $hex_representation"
done





share|improve this answer
















  • 2




    Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
    – steeldriver
    Mar 24 at 11:49










  • This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
    – RainyDay
    Mar 26 at 3:37














up vote
1
down vote













Just play with the print operators



#!/bin/bash
for number in $( seq 1 255 )
do
hex_representation=$( printf "%X" $number )
echo "$number: $hex_representation"
done





share|improve this answer
















  • 2




    Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
    – steeldriver
    Mar 24 at 11:49










  • This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
    – RainyDay
    Mar 26 at 3:37












up vote
1
down vote










up vote
1
down vote









Just play with the print operators



#!/bin/bash
for number in $( seq 1 255 )
do
hex_representation=$( printf "%X" $number )
echo "$number: $hex_representation"
done





share|improve this answer












Just play with the print operators



#!/bin/bash
for number in $( seq 1 255 )
do
hex_representation=$( printf "%X" $number )
echo "$number: $hex_representation"
done






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 4:04









vfbsilva

2,54211225




2,54211225







  • 2




    Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
    – steeldriver
    Mar 24 at 11:49










  • This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
    – RainyDay
    Mar 26 at 3:37












  • 2




    Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
    – steeldriver
    Mar 24 at 11:49










  • This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
    – RainyDay
    Mar 26 at 3:37







2




2




Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
– steeldriver
Mar 24 at 11:49




Or just printf '%06Xn' $(seq 1 255) (I added zero padding in line with the OP's desired output format)
– steeldriver
Mar 24 at 11:49












This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
– RainyDay
Mar 26 at 3:37




This answer is also a good solution. In the loop how can I control the output? In the loop 0000001 is sent to an empty file like this: printf '%06Xn' $(seq 1 255) > file. Then on second loop cycle 0000002 is sent into the file, etc. Is there a simple way to pause this command until next loop?
– RainyDay
Mar 26 at 3:37












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433197%2fbash-increment-alphanumeric-data-from-command-prompt%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay