ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hi, I'm trying to make a script that reads from a file, if the words "ADD" occures the function AddName should be called with the name that follows as an argument
The problem is that awk cuts away the newline or something like that. Why?? Can someone help me?
# This is the file i read from
Blablabla;test
ADD;Tom
blabla;ok
ADD;Mark
# This is the script
function AddName()
{
echo "Added"
}
temp=`awk -F";" '
{
if ( $0 ~/^'"#"'/ )
{
# Ignore "#"
}
else
{
if ( $1 == "ADD" )
{
print "AddName "$2
}
fi
}' file`
$temp
exit 0
The output if I echo it would be:
AddName Tom AddName Mark
Nope, that just returned the error: "backslash not last character on line"
I also tried:
print "AddName "$2"\n"
printf "AddName "$2
printf "AddName "$2\n
printf "AddName "$2"\n"
\n seems to output a <space>
now i have tried with \f and \r as well. With \f\r it came on seperate lines when i echoed it, but it would not run, I think because in "reality" it is still on one line.. Any other suggestions?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.