05-16-2012
Yes I believe the Bourne shell (sh) does not support arrays. Are you able to run my complete example? Make sure to include the first line, it tells whatever your login shell is to use the korn shell to execute the script.
You may have better luck using bash (bourne again shell) heh on Linux.
This User Gave Thanks to gary_w For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is there any way to convert a string into an array in KSH? In other words I want to split the string like this:
STRING="one two three four"
into an array of 4 values splitting on white space. The array should be similar to the one that would be created with the following command:
... (3 Replies)
Discussion started by: piooooter
3 Replies
2. Shell Programming and Scripting
I need to split a long varible which is a whole line read from a file into fields and store them in an array, the fields are delimited by pipe and a field may contain white spaces.
I tried the following concept test and it has problem with field 5 which contain a space, appearently so because... (3 Replies)
Discussion started by: gratus
3 Replies
3. Shell Programming and Scripting
Hi all,
I have a file of around 300 lines in which string "SERVER" occurs around 32 times.
for eg.
I need to split files like, for eg
I am using this code
awk '/SERVER/{n++}{print > f n}' f=/vikas/list /vikas/final
But the problem is that it makes maximum of 10 files, but I... (12 Replies)
Discussion started by: vikas027
12 Replies
4. Shell Programming and Scripting
Hi,
How do I parse/split lines (strings) read from a file and display the individual tokens in a shell script? Given that the length of individual lines is not constant and number of tokens in each line is also not constant.
The input file could be as below:
... (3 Replies)
Discussion started by: yajaykumar
3 Replies
5. Shell Programming and Scripting
i need one help....
if i have a string like aaaaa,bbbbb,ccccc,aaaaa
How to to split the string and check howmany times aaaaa will be in that string?
Thanks (7 Replies)
Discussion started by: karthinvk
7 Replies
6. Shell Programming and Scripting
Hi all,
I want to create an array variable in shell, for example:
#!/bin/sh
name="foo"
name="bar"
name="baz"
But above code didn't work, I also tried with:
name=(foo bar baz)
and
set -A name foo bar baz
but none of these worked.
Another question is how to know the shell... (6 Replies)
Discussion started by: Roy987
6 Replies
7. Shell Programming and Scripting
Hello,
I was trying to split a string to characters by perl oneliner.
echo "The quick brown fox jumps over the lazy dog" | perl -e 'split // ' But did not work as with bash script pipe:
echo "The quick brown fox jumps over the lazy dog" | fold -w1 | sort | uniq -ic 8
1 T
1... (6 Replies)
Discussion started by: yifangt
6 Replies
8. Shell Programming and Scripting
Hi
Input:
{ committed = 782958592; init = 805306368; max = 1051394048; used = 63456712; }
Result:
A map (maybe Associative Array) where I can iterate through the key/value. Something like this:
for key in $map
do
echo key=$key value=$map
done
Sample output from the map:
... (2 Replies)
Discussion started by: chitech
2 Replies
9. UNIX for Beginners Questions & Answers
value=malayalam
# i need to store the value in an array by splitting the character
#the output i need is
m
a
l
a
y
a
l
a
m
Please use CODE tags for output data as well as required by forum rules! (5 Replies)
Discussion started by: Meeran Rizvi
5 Replies
10. UNIX for Beginners Questions & Answers
Test1.txt
Tom is hot
Test.sh
filename="/directory/Test1.txt"
set - A store
while IFS= read value
do
awk '{split($value,store," ")}'
done < "$filename"
echo ${#sore}
From the code in the executing file, I would like each... (8 Replies)
Discussion started by: TestKing
8 Replies
OPEN(1) Linux 1.x OPEN(1)
NAME
open - start a program on a new virtual terminal (VT).
SYNOPSIS
open [-c vtnumber] [-s] [-u] [-l] [-v] [--] command command_options
DESCRIPTION
open will find the first available VT, and run on it the given command with the given command options, standard input, output and error are
directed to that terminal. The current search path ($PATH) is used to find the requested command. If no command is specified then the envi-
ronment variable $SHELL is used.
OPTIONS
-c vtnumber
Use the given VT number and not the first available. Note you must have write access to the supplied VT for this to work.
-s Switch to the new VT when starting the command. The VT of the new command will be made the new current VT.
-u Figure out the owner of the current VT, and run login as that user. Suitable to be called by init. Shouldn't be used with -c or -l.
-l Make the command a login shell. A - is prepended to the name of the command to be executed.
-v Be a bit more verbose.
-w wait for command to complete. If -w and -s are used together then open will switch back to the controlling terminal when the command
completes.
-- end of options to open.
NOTE
If open is compiled with a POSIX (Gnu) getopt() and you wish to set options to the command to be run, then you must supply the end of
options -- flag before the command.
EXAMPLES
open can be used to start a shell on the next free VT, by using the command:
open bash
To start the shell as a login shell, use:
open -l bash
To get a long listing you must supply the -- separator:
open -- ls -l
SEE ALSO
login(1), doshell(8), switchto(1).
AUTHOR
Jon Tombs <jon@gtex02.us.es or jon@robots.ox.ac.uk>
-w idea from "sam".
19 Jul 1996 V1.4 OPEN(1)