![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to trim the white space around a string in C program | hxm1303 | High Level Programming | 18 | 10-17-2008 07:43 AM |
| Remove unregconized space from a string | Ricole | UNIX for Dummies Questions & Answers | 3 | 02-29-2008 01:35 AM |
| Storing string with space | rahul303 | Shell Programming and Scripting | 4 | 10-04-2007 07:26 AM |
| Need help to seperate data | getdpg | Shell Programming and Scripting | 4 | 08-30-2006 02:28 AM |
| row seperate | inquirer | Shell Programming and Scripting | 13 | 08-12-2003 02:26 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Dear Members,
I have string like this string1="file2.txt file4.txt kittu.txt file1.txt" in this i need to cut spaces and take each one has one file output should be --------- fileslist:4 file2.txt file4.txt kittu.txt file1.txt is it possible, please tell me how it possible thanks Krish. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
ksh:
for i in `cat filename` do echo $i done |
|
#3
|
|||
|
|||
|
Hi,
its not file its string string1="file2.txt file4.txt kittu.txt file1.txt" echo $string1 for i in `cat string1` do echo $i done but its not working |
|
#4
|
|||
|
|||
|
You had an error because you don't have a file called string1.
try this: Code:
string1="file2.txt file4.txt kittu.txt file1.txt" for i in `echo $string1` do echo $i done Code:
string1="file2.txt file4.txt kittu.txt file1.txt" for i in $string1 do echo $i done |
|
#5
|
|||
|
|||
|
Thank you boss its workingggggg fineeeeeeeeee
thank youuuuuuuuuu |
|
#6
|
|||
|
|||
|
You can also use the cut utility for this purpose...
Code:
firstfield=`echo $string1 | tr -s " " | cut -d " " -f 1` echo $firstfiled |
|||
| Google The UNIX and Linux Forums |