kash
1
Hi
I need help i Loop format
If i use the Following syntax
$ for i in `echo "Hello world"`
do
echo $i
done
Output is:
Hello
world
But i need Output in One line "Hello world"
Can any one help?
If i use while loop it works?
I want to use for loop only.
Thanks in advance
Here is what you want, but why do an echo of that? AN echo "hello world" would give you what you request
for i in "echo hello world"
do
echo $i
done
kash
3
Hi
Thanks for your prompt response.
Here is my question:
In My script at some place I'm reading one file in for loop:
cat file_name
abc|xyz|Hello World|
for i in `cat file_name`
do
x=echo $i|cut -f1 d'|'
y=echo $i|cut -f2 d'|'
z=echo $i|cut -f3 d'|'
command1
perform action
command2
perform action
done
The above for loop result is splitting into 2
abc|xyz|Hello
World
I want to read "Hello World" as one argument
please help
Thanks
have a try with awk instead of cut, it should be ok after.
This sounds like school work, be aware that it's not excepted here..
Cheers
Jason
Phantom
5
for i in `echo "Hello world"`
do
echo "$i \c"
done
#!/bin/ksh
while IFS='|' read command1 command2 command3 junk
do
echo "[$command1]"
echo "[$command2]"
echo "[$command3]"
done < file_name
kash
7
Thanks for your response and support.
I managed to solve the problem.
Converting spaces into strings and putting it back. coz "for loop" can't read as continuous line if there is space in between (as i know)
cat file_name
abc|xyz|Hello World|
xas|ewe| Simple QA|
(Here i know space is only for 3rd argument)
for i in ``awk '{gsub(" ",",");print}' file_name`
do
x=echo $i|cut -f1 d'|'
y=echo $i|cut -f2 d'|'
z=echo $i|cut -f3 d'|' | awk '{gsub(","," ");print}'`
command1
perform action
command2
perform action
done