ksh - building a var


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh - building a var
# 8  
Old 02-20-2014
Thanks to all for the input.

Using (basiclly) sea's solution.
No ... this isnt homework.


This did bring up another question. Ill post in different thread.

Thanks again to all .. this is a great resource.
This User Gave Thanks to popeye For This Post:
# 9  
Old 02-20-2014
OSX 10.7.5, default bash terminal...
Not sure if this is what you are after but........
From the command line:-
Code:
Last login: Thu Feb 20 19:35:40 on ttys000
AMIGA:barrywalker~> somefunction() { date ; }
AMIGA:barrywalker~> for n in {1..5} ; do text=$text$n') This is a useless string.'$'\n'$(somefunction)$'\n' ; sleep 2 ; done
AMIGA:barrywalker~> printf "$text"
1) This is a useless string.
Thu 20 Feb 2014 20:05:43 GMT
2) This is a useless string.
Thu 20 Feb 2014 20:05:45 GMT
3) This is a useless string.
Thu 20 Feb 2014 20:05:47 GMT
4) This is a useless string.
Thu 20 Feb 2014 20:05:49 GMT
5) This is a useless string.
Thu 20 Feb 2014 20:05:51 GMT
AMIGA:barrywalker~> _

This was fun...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transfer the logs being thrown into /var/log/messages into another file example /var/log/volumelog

I have been searching and reading about syslog. I would like to know how to Transfer the logs being thrown into /var/log/messages into another file example /var/log/volumelog. tail -f /var/log/messages dblogger: msg_to_dbrow: no logtype using missing dblogger: msg_to_dbrow_str: val ==... (2 Replies)
Discussion started by: kenshinhimura
2 Replies

2. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

ksh : Building an array based on condition result

I want to build an Errorlog. I would like to build an array as I move through the if statements and print the array once all error conditions have been defined. The results need to be comma delimited. tsver will be static "1.9.6(2)" other vars $prit $lt $rt can have the same or a different... (1 Reply)
Discussion started by: popeye
1 Replies

4. Solaris

Difference between /var/log/syslog and /var/adm/messages

Hi, Is the contents in /var/log/syslog and /var/adm/messages are same?? Regards (3 Replies)
Discussion started by: vks47
3 Replies

5. Solaris

/var/adm & /var/sadm

what is the difference between tha /var/adm and /var/sadm files in solaris 10 Os please can any one respond quickly thanking you (2 Replies)
Discussion started by: wkbn86
2 Replies

6. Shell Programming and Scripting

ksh: what does var=$(command) mean?

hi, i can see in a script it contains var=$( myFile | grep -i err ) why has this person done it like this? why not just var=`myFile | grep -i err` thanks (9 Replies)
Discussion started by: JamesByars
9 Replies

7. Shell Programming and Scripting

${!var} does not work in ksh

Anyone knows why the following function does not work in ksh (it does in bash)? var() # Displays var value; case insensitive { _var="$1" if ; then echo ${!_var} else _var=$(echo "$_var" | tr 'a-z' 'A-Z') echo ${!_var} fi unset _var }$ var home ksh:... (4 Replies)
Discussion started by: victorbrca
4 Replies

8. Shell Programming and Scripting

How to use shell var for pattern string at KSH

Hi there, In the following test, how to use shell var for pattern, regular expression. I need to accept pattern at argument, use it to pattern matching at shell script. Test: #!/bin/ksh # name t.sh exp="a@(a|b)" touch aa ab ac echo "\nTest without variable" echo "---------------------"... (2 Replies)
Discussion started by: tkang007
2 Replies

9. Solaris

diff b/w /var/log/syslog and /var/adm/messages

hi sirs can u tell the difference between /var/log/syslogs and /var/adm/messages in my working place i am having two servers. in one servers messages file is empty and syslog file is going on increasing.. and in another servers message file is going on increasing but syslog file is... (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

10. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies
Login or Register to Ask a Question