Is there any command in the Bourne shell?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is there any command in the Bourne shell?
# 1  
Old 05-05-2010
Is there any command in the Bash shell?

Hi,


The problem I have is that I want to create a list of folders whose names are read from a text file but the file names are in decimal. Each letter consists of an octet and the end of the folder name is defined by the white space character (0032)

For example, we have in the text file:
Code:
0104011101080097 0032 00970064006901110115

The folders are:
Code:
0104011101080097 -> hola
0032 -> espacio en blanco (fin de nombre de fichero)
00970064006901110115 -> adios

The problem is that I have not found any command that I converted from decimal to ASCII and I have to work in the bash shell (I can not use awk because it belongs to bash)
Does anyone know how I can do?

Last edited by zaxxon; 05-05-2010 at 07:19 AM.. Reason: use code tags please, ty
# 2  
Old 05-05-2010
I'm confused - your thread title talks about the Bourne shell, you then say you are using bash, then you cannot use awk because it is part of bash. Usually requirements like that are homework. Normally you pick the right tool, you do not limit yourself by saying 'I cannot use awk'.

Can you use perl?

And you do understand that we have a special forum for homework - which this sounds like?
# 3  
Old 05-05-2010
Small problem with the data. The second word does not spell "adios".

Code:
DEC=0097  OCT=141  CHAR=a
DEC=0064  OCT=100  CHAR=@
DEC=0069  OCT=105  CHAR=E
DEC=0111  OCT=157  CHAR=o
DEC=0115  OCT=163  CHAR=s
a@Eos

DEC=0097  OCT=141  CHAR=a
DEC=0100  OCT=144  CHAR=d
DEC=0105  OCT=151  CHAR=i
DEC=0111  OCT=157  CHAR=o
DEC=0115  OCT=163  CHAR=s
adios

I used "bc" to convert from decimal to octal then echo to display the character. Neither of these commands are in bash so there is no point in posting my code.

---------- Post updated at 15:35 ---------- Previous update was at 12:18 ----------

One way to convert from decimal to ascii in modern shell (e.g. bash). There may be better methods.

This script outputs the letter "a" by converting decimal 97 to octal 141 (which is held as 8#141) removes the "8#" prefix then outputs the character equivalent of octal 141 with "print".

Code:
typeset -i8 OCT         # Octal number
typeset -i10 DEC        # Decimal number
DEC=97
OCT=${DEC}
# ${OCT} now contains 8#octal_no
# remove 8# prefix
OCT2=${OCT##8#}
print "\0${OCT2}"


Last edited by methyl; 05-05-2010 at 08:24 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Alias Command in Bourne Shell

Hi My Unix sever is AIX 5.3. My Login shell ( using echo $SHELL) is /bin/sh implying it is a Bourne Shell. My Question is that i am still able to use Alias command to create/retrieve aliases. I have read in several sites on Unix online that the Bourne Shell does not support Aliases but... (12 Replies)
Discussion started by: pchegoor
12 Replies

2. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

3. UNIX for Dummies Questions & Answers

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (5 Replies)
Discussion started by: ajaira
5 Replies

4. UNIX for Advanced & Expert Users

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (1 Reply)
Discussion started by: ajaira
1 Replies

5. Shell Programming and Scripting

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (1 Reply)
Discussion started by: ajaira
1 Replies

6. Shell Programming and Scripting

I need to understand the differences between the bash shell and the Bourne shell

I do not claim to be an expert, but I have done things with scripts that whole teams of folks have said can not be done. Of course they should have said we do not have the intestinal fortitude to git-r-done. I have been using UNIX actually HPUX since 1992. Unfortunately my old computer died and... (7 Replies)
Discussion started by: awk_sed_hello
7 Replies

7. Shell Programming and Scripting

Maximum command length in bourne shell

Hi, I wanted to know what is the maximum length of command which can be run on a bourne (sh) shell? Where can I find that information? Is it different for different OS flavors? Please help. Thanks, Vineet (10 Replies)
Discussion started by: vineetd
10 Replies

8. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

10. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies
Login or Register to Ask a Question