File FTP from windows system without any compression, only data got compressed, we need to expand the data by finding the special character ie. "ú07 & ú1A?.," lies in the file and to pad the next byte ie(space or ?) after the hexadecimal value convert to decimal.
Please use CODE tags as in the forum rules. You have two warning already.
Using CODE tags means that the output will be fixed-width characters and multiple spaces will be respected
Your sample output seems to assume that the two characters after the ú are hex digits if at least one of those two characters is a hex digit greater than 9, but are decimal digits if both of those two characters are decimal digits (i.e., 14 is treated as decimal 14 instead of decimal 20). Assuming your original description was what you want (always treat those two characters as hex), the following straight forward awk script seems to do what you want:
With the input file Input containing:
produces the output:
or, if you remove the octothorpes in red that turn the tracing printf statements into comments, you can see how it processes each four character string starting with ú:
Thanks for your input. While running the script we are not getting the output and also I need to write the output in a file. Could you please help out on this.
Script
Sample.dat
Thanks,
Dines
---------- Post updated at 01:38 AM ---------- Previous update was at 12:38 AM ----------
One more point if it is decimal use the same else convert it to decimal from hexadecimal.
Thanks,
Dines
---------- Post updated at 05:13 AM ---------- Previous update was at 01:38 AM ----------
Hi Don Cragun,
Ran the script but the ouput is not as expected. Please find the code & output below. Facing problem while converting to hexadecimal
We changed the input file name the code it's not working
Script
Input:
Output:
Thanks,
Dinesh
It is no surprise that the conversion:
failed. Removing the quotes from the code I suggested:
will not work. I'm surprised that you didn't get a syntax error from this.
Yes, I see the problem. The code I provided works fine on OS X, and I don't have a Solaris system available for testing. I'll have something that should work on any system in less than two hours.
Let's try once more... The following awk script will handle decimal and hexadecimal digits following the ú introducing character; and will print an error message in the output file if non-decimal, non-hexadecimal characters are found (and, in this last case, exit with a non-zero exit status):
when sample.dat contains:
writes the following in output.dat:
or, with the debugging printf() calls enabled:
A Merry Xmas to all of you.
And, as a special present to vbe (he knows why) a little exercise:
#! /bin/ksh
pPrintSnow ()
{
typeset -i iLen=$1
while (( iLen )) ; do
if ! (( RANDOM % 31 )) ; then
printf "%1s" "."
else
printf "%1s" " "
fi
((... (0 Replies)
Hi,
I have a string wherein i need to replace special characters with backslash and that character.
Ex:
If my string is a=qwerty123@!,
then the new string should be a_new=qwerty123\@\!\,
Thanks (3 Replies)
Hello
I created 3 files by:
dd if=/dev/urandom bs=1024 count=1000000 of=./testfile1
dd if=/dev/urandom bs=1024 count=5000000 of=./testfile2
dd if=/dev/urandom bs=1024 count=10000000 of=./testfile3
Now I want to know how to make a change in a specific byte and/or line of theses files? (2 Replies)
Hi,
I have a requirement to search for a pattern in each line in a file and remove the in between words till the 3rd occurrence of double quote (").
Ex: CREATE TABLE "SCHEMANAME"."AMS_LTV_STATUS"
(Note: "SCHEMANAME" may changes for different schemas. Its not a fixed value)
I need to... (2 Replies)
How can I replace the follong text including to number 7000?
cat tmp0.txt
Winston (UK) Wong
I would the 7000 to replace Winston (UK) Wong.
I fail with method below:
sed ' s /Winston\(UK\)Wong/7000 tmp0.txt' (1 Reply)
I would like to replace /n with ',' and after replace remove last semicolon then put a open brace in starting and closing brace in end of line. See below example:
input:
1234
3455
24334
234
output:
('1234,'3455',24334','234')
Thanks (3 Replies)
Hi,
I am beginner to Shell Scripting.
I have a String like this "testabcdef", i need the first character as it is and the remaining character should be replaced by the the '*' character. e.g(t***********)
PLZ Suggest me. (5 Replies)
I need to do the following:
text in the format of: ADDRESS=abcd123:1111
- abcd123:1111 is different on every system.
replace with: ADDRESS=localhost:2222
sed 's/ADDRESS=<What do I use here?>/ADDRESS=localhost:2222/g'
Everything I've tried ends up with:
... (3 Replies)