Click HereHello dani.
I know how to write to a file using redirection. But I am unable to write a record to every new line. I want it this way
alex amsterdam 800 7
But I am ending up putting everything in a new line, I mean the fields or overwritting with the last value. I need to perform some operations on this set of values, but I am unable to create the file that way. Thanks in advance.

Your link doesn't work.

The link is not deliberately provided,it is a mistake. My question is what you can see in the box. If you dont understand the question properly here it is:
When i write a new value to a file like this echo $name>>filename (for append) and echo $name>filename just for writting, the former just adds the new words to the end file in a new line and the later overwrites just the last field which was written in the file,hence resulting in a single word throughout. All I am asking you is to show me the method to insert each new record in a new line so that I can cut columns to work.

Are you trying to insert lines in-between, like in the middle of the file.

And what do you mean by 'cut columns to work'. Can you give a complete example of what you are trying to do. Like the input you have and output you want..

NO I just want to insert lines,please notes lines are different variables taken input from user. LiKe
echo "enter name"
read name
echo "enter salary"
read salary
echo "enter age"
read age
//now I want to write lines like this in a new file
name salary age
There will be record of n different persons like this
name salary age
name1 salary1 age1
name2 salary2 age2
so that I can extract columns and do the work. Evry new record will be appended.

(I'm assuming you're runnng on Unix/Linux, and not Windows)

By default, the echo command automatically adds a new-line to the end of every line it prints. How to change this depends on which shell you're using. Try these commands and see whether the output appears on the same line as the prompt for your next command.

echo -n Hello

or

echo Hello \\c

Alternatively wait until you've got a full line and then print it out at once:

echo $name $salary $age

it seems he wants an awk readable format

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.