Read format problem in ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read format problem in ksh script
# 1  
Old 06-30-2011
Read format problem in ksh script

I have ksh script reading file like
Code:
while read -r line
do
  echo $line
  sleep 1
#process_file $line
done<$file_nm

I want to write this line to another file after some manuplation.Put $line giving me line after changing line format(space removed).Please help me how can i read line by keeping line format same

Last edited by Franklin52; 06-30-2011 at 12:07 PM.. Reason: Please indent your code and use code tags
# 2  
Old 06-30-2011
try like this,
Code:
echo "$line" > newfile

# 3  
Old 06-30-2011
Code:
$ echo "         xxx     " | read var; echo "[$var]"
[xxx]
$ echo "         xxx     " | IFS= read var; echo "[$var]"
[         xxx     ]
$

Jean-Pierre.
# 4  
Old 06-30-2011
i want to read file and put line in variable for some editing.Then i have to write that line to another file.
Please help me how i can read line without omitting space which is changing my output file format
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass and read an array in ksh shell script function.?

I'm able to read & print an array in varaible called "filelist" I need to pass this array variable to a function called verify() and then read and loop through the passed array inside the function. Unfortunately it does not print the entire array from inside the funstion's loop. #/bin/ksh... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. UNIX for Dummies Questions & Answers

problem in Executing script in ksh

Hi, I am in ksh. below mentioned 3 commands I executed at command prompt & got the expected results. csh source csh_infa <special command> Now I have to do this in the script in ksh. I entered it as it is. #!/bin/ksh csh source csh_infa <special command> Now after... (1 Reply)
Discussion started by: girish_kanak
1 Replies

3. Shell Programming and Scripting

String format in KSH script

Hello, I am attempting to format the output of my unix ksh script. Currently looks like ... FTP TO HR : Down FTP FROM HR 4011a : Up FTP FROM HR 4019a : Down FTP FROM HR : Down Would like the status to be aligned as follows: ... (4 Replies)
Discussion started by: dvella
4 Replies

4. Shell Programming and Scripting

Problem with script: ksh not found

Hello Guys, what is the significance of using #!/bin/sh at the start of shell script. my default shell is ksh, when i run my script i have ksh: not found error and when i use ./myscript it works. Can anyone explain me the problem please ? tnx (1 Reply)
Discussion started by: midhun_u
1 Replies

5. UNIX for Dummies Questions & Answers

script sourcing problem (ksh)

I have a script "abc.sh" in /tmp which has exit 0 as its last line when I run this script from /tmp/xyz/def.sh script as . ../abc.sh then the script executes but the control doesn't return to def.sh script for subsequent commands in def.sh but if I invoke the abc.sh from inside the... (3 Replies)
Discussion started by: rakeshou
3 Replies

6. Shell Programming and Scripting

Ksh problem in script

Hi I made a small script which uses ksh. When i run the script then i get the following error However when i run each of the commands on the commandline they get executed and provide the desired output. i cant figure out why the script is not running. Kindly Help Thanks in... (3 Replies)
Discussion started by: PradeepRed
3 Replies

7. Shell Programming and Scripting

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (3 Replies)
Discussion started by: amarnath
3 Replies

8. Shell Programming and Scripting

Newbie problem with ksh script

Hi all, I have a directory have all of the .stat and .dat file : they are is a pipe separate flat file. Example: log-20061202.stat contain 1st line and last line of log-20061202.dat with record count of that day. Example: Total record = 240 Tom|02-12-2006|1600 W.Santa... (18 Replies)
Discussion started by: sabercats
18 Replies

9. Shell Programming and Scripting

Simple ksh script problem

This is a search script that I have developed. It finds the records that I look for. However the only thing I want the program to do now is to display a message such as 'Not Found' to appear when a record is not found. So far when a search doesn't display a record, the screen is blank. ... (14 Replies)
Discussion started by: Warrior232
14 Replies

10. Shell Programming and Scripting

ksh script and java problem

I have a problem with the execution of a ksh as deamon on linux. I explain you first the context. We have developped a Java program that execute every minutes an external (that we don't have developped) program with a config file in parameter. The Java program is runned as deamon with a perl... (0 Replies)
Discussion started by: adrian.mihai
0 Replies
Login or Register to Ask a Question