This is the finished hex dumper for my new Android phone and it is running just great.
Believe it or not it is marginally quicker than the OSX version... <shock>
Code:
#!/system/bin/sh
# [./]hex </full/path/to/filename> ['delimiter_character']<CR>
if [ "$1" == "" ]
then
echo "Usage: [./]hex </full/path/to/filename> ['delimiter_character']<CR>"
exit 1
fi
. /storage/sdcard0/Home/bin/ENVARC
ifs_str="$IFS"
IFS=""
if [ ! -f $TMPDIR/00.HEX ]
then
for high_nibble in 0 1 2 3 4 5 6 7 8 9 A B C D E F
do
for low_nibble in 0 1 2 3 4 5 6 7 8 9 A B C D E F
do
echo -e -n "\x$high_nibble$low_nibble" > $TMPDIR/$high_nibble$low_nibble'.HEX'
done
done
fi
listing=$(ls $TMPDIR/*.HEX)
count=0
char=""
hexval="$TMPDIR/00.HEX"
subscript=0
chr=""
while read -s -d '' -r -n 1 char
do
subscript=0
count=0
while [ $count -le 255 ]
do
hexval="${listing:$subscript:${#hexval}}"
chr=$(cat $hexval)
if [ "$char" == "$chr" ]
then
if [ "$chr" == "" ]
then
echo -n "00$2"
break
fi
if [ "$chr" != "" ]
then
echo -n "${hexval:$((${#hexval}-6)):2}$2"
break
fi
fi
subscript=$((subscript+${#hexval}+1))
count=$((count+1))
if [ $count -eq 256 ]
then
echo -n "0A$2"
fi
done
done < $1
IFS="$ifs_str"
exit 0
The absolute address(es) I had to create manually...
ENVARC is this file too...
Note that TMPDIR does not exist in Android so why not use it... ;o)
Also tr and dos2unix do not exist either so this is another tool for the phone generated from minimal Android tools...
This is a dos2unix work-alike...
Code:
#!/system/bin/sh
# [./]d2u <infile> [outfile]<CR>
. /storage/sdcard0/Home/bin/ENVARC
ifs_str="$IFS"
IFS=""
newfile=""
substring=0
outfile=$2
if [ "$1" == "" ]
then
echo "Usage: [./]d2u <infile> [outfile]..."
exit 1
fi
if [ "$2" == "" ]
then
outfile=$1
fi
read -s -d '' -r oldfile < $1
while [ $substring -lt ${#oldfile} ]
do
if [ "${oldfile:$substring:1}" == $'\r' ]
then
substring=$((substring+1))
else
newfile=$newfile${oldfile:$substring:1}
substring=$((substring+1))
fi
done
IFS="$ifs_str"
echo -n "$newfile" > $outfile
echo "File, $1, now converted to UNIX format..."
exit 0
Hi,
When I do /usr/ucb/echo "message \n" in bone shell program , \n never works as new line feeder. It just showed it as part of my message.
Is there something wrong with my system?
Thanks! (3 Replies)
I tried echo ^[[r and it takes the cursor to first line in the telnet window...
and echo ^[[32m changes font color to green .... Also echo ^[[00ff takes cursor to first command line in the current window (Note : ^ is entered as Ctrl + V and first [ as Escape character)
Wud like to know how... (1 Reply)
So in my shell i execute:
{ while true; do echo string; sleep 1; done } | read line This waits one second and returns.
But
{ while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly.
I have tried this in bash as well as zsh,... (2 Replies)
Hi All,
Need help in resoving the issue . Can anyone let me know how to get fix length using unix shellscript.
For Ex: echo "NUMBER OF RECORDS "${NO_OF_ROWS}"\nFILE CREATION DATE&TIME "${PROD_DT}"
output should be :
NUMBER OF RECORDS 2546
CREATIN DATE&TIME 2009-12-01
Each... (14 Replies)
Bit of a weird one i suppose, i want to use an echo inside an echo... For example...
i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos...
echo "echo "hello"" >$file
echo "echo "goodbye"" >$file
... (3 Replies)
Hi Guys,
I need to print a value in the same line , But when we use the echo instead the loops (while), the value goes to the next line..
Can you help me in this..
Thanks For your help in advance. (6 Replies)
echo `echo ` doesn't echoes anything. And it's logic. But
echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo"
(too much echoing :P):o (2 Replies)
I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here.
I have following script (called out_to_streams.csh):
#!/bin/tcsh -f
echo Redirected to STDOUT > /dev/stdout
echo Redirected to... (2 Replies)
Hi guys,
Been messing around with shell programming for a couple of days and I found something that was pretty odd in the behavior of the echo command. Below is an example-:
When I type the following in my /home directory from my lxterminal in Debian-:
echo "`ls -l`"
I get the... (2 Replies)
Hi guys...
I haven't done any real Python code since I started messing with Shell Scripting in January 2012 when I started AudioScope.
Well I fished a little project out of my ANCIENT AMIGA files which created a raw hexdump of any binary file within reason for a stock A1200(HD).
Well... (0 Replies)
Discussion started by: wisecracker
0 Replies
LEARN ABOUT SUNOS
diffmk
diffmk(1) User Commands diffmk(1)NAME
diffmk - mark differences between versions of a troff input file
SYNOPSIS
diffmk oldfile newfile markedfile
DESCRIPTION
diffmk compares two versions of a file and creates a third version that includes "change mark" (.mc) commands for nroff(1) and troff(1).
oldfile and newfile are the old and new versions of the file. diffmk generates markedfile, which, contains the text from newfile with
troff(1) "change mark" requests (.mc) inserted where newfile differs from oldfile. When markedfile is formatted, changed or inserted text
is shown by | at the right margin of each line. The position of deleted text is shown by a single *.
USAGE
See largefile(5) for the description of the behavior of diffmk when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes).
EXAMPLES
Example 1: An example of the diffmk command.
diffmk can also be used in conjunction with the proper troff requests to produce program listings with marked changes. In the following
command line:
example% diffmk old.c new.c marked.c ; nroff reqs marked.c | pr
the file reqs contains the following troff requests:
.pl 1
.ll 77
.nf
.eo
.nh
which eliminate page breaks, adjust the line length, set no-fill mode, ignore escape characters, and turn off hyphenation, respectively.
If the characters | and * are inappropriate, you might run markedfile through sed(1) to globally change them.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWdoc |
+-----------------------------+-----------------------------+
SEE ALSO diff(1), nroff(1), sed(1), troff(1), attributes(5), largefile(5)BUGS
Aesthetic considerations may dictate manual adjustment of some output. File differences involving only formatting requests may produce
undesirable output, that is, replacing .sp by .sp 2 will produce a "change mark" on the preceding or following line of output.
SunOS 5.10 14 Sep 1992 diffmk(1)