Added my basic hex/ascii/binary conversion scripts

This commit is contained in:
Brian Buller 2017-05-25 07:36:04 -05:00
parent e5467a1f64
commit 13066b37d7
4 changed files with 59 additions and 1 deletions

View File

@ -1,3 +1,41 @@
# bash-utils # bash-utils
Just a couple bash utilities Just a couple bash utilities
= a2b - Convert Ascii to Binary =
== Usage ==
```
a2b H e l l o
```
== Output ==
```
01001000
01100101
01101100
01101100
01101111
```
= a2h - Convert Ascii to Hex =
== Usage ==
```
a2h H e l l o
```
== Output ==
```
48
65
6c
6c
6f
```
= h2a - Convert Hex to Ascii =
== Usage ==
```
h2a 48 65 6c 6c 6f
```
== Output ==
```
H e l l o
```

5
a2b Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
for c in $@; do
echo $c | xxd -b | cut -d" " -f2
done

5
a2h Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
for c in $@; do
echo $c | xxd -p | cut -c1-2
done

10
h2a Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
for c in $@; do
if [[ $c != 0x* ]]; then
c="0x$c"
fi
echo $c | xxd -r
echo -n " "
done
printf "\n"