LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags , , , ,

Reply
 
Thread Tools
Old 08-16-2009, 09:09 AM   #1
jayant4285@gmail.com
LQ Newbie
 
Registered: Aug 2009
Posts: 1
Thanked: 0
Taking the value from user


[Log in to get rid of this advertisement]
Hi,

As shown in the program how can "rf" will take the value of "filename"
what should be the code ....?



BEGIN{
}

#
# main logic is here
#

{
printf "Enter fime namr: "
getline filename < "-"

rpcmd = "sed 's/rf/uuu/' file > file1 "
system(rpcmd)


}

#
# End action, if any, e.g. clean ups
#
END{
}
jayant4285@gmail.com is offline  
Tag This Post , , , ,
Reply With Quote
Old 08-16-2009, 10:40 AM   #2
onebuck
Guru
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 5,440
Blog Entries: 1
Thanked: 202
Hi,

Welcome to LQ!

I smell homework here?

Please read the LQ rules.
onebuck is offline     Reply With Quote
Old 08-16-2009, 11:06 AM   #3
colucix
Guru
 
Registered: Sep 2003
Location: Bologna, Italia
Distribution: OpenSUSE 11.1 CentOS 5.4 VectorLinux 6.0
Posts: 5,129
Thanked: 464
Hi and welcome to LinuxQuestions.

As already stated by onebuck, we don't give help for homework questions. The best way to learn is to try again and again until you find the answer by yourself. I can only suggest to read the official GNU awk user's guide, which is a very good text for learning the awk secrets. In chapter 5 you will find the answer to your question. In any case, show us your efforts and maybe we'll give some more specific directions.

Last edited by colucix; 08-16-2009 at 11:07 AM..
colucix is offline     Reply With Quote
Old 08-16-2009, 11:36 AM   #4
pixellany
Moderator
 
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch
Posts: 13,130
Thanked: 281
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.

Note: We can help with homework, but you need to tell us more about the class, what books you are using, etc. In this case, have you used assignment statements to set the value of a variable?
pixellany is offline     Reply With Quote
Old 08-16-2009, 01:46 PM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 2,847
Thanked: 78
That code looks like it's intended to be part of an AWK program. Is that correct? If so, you need something like rf=filename since that's the variable you read from "-."

Note, however, that your system call string (rpcmd = "sed 's/rf/uuu/' file > file1") is not correctly formatted. You need something like rpcmd = "sed \'s/" rf "/uuu/\' file > file1"

And, if you're using AWK, why bother using sed to do a simple substitution in a file that could be done easily in AWK itself?
PTrenholme is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Taking RHCE again rajaguru14 Linux - Newbie 2 11-24-2008 05:42 AM
[ruby with emacs] taking user input lilili Programming 2 01-18-2007 01:17 PM
Why I'm taking the plunge tanstaafl4y LinuxQuestions.org Member Intro 2 10-30-2006 01:33 PM
Taking my first steps. ellion Linux - Newbie 4 05-11-2006 02:13 AM
Taking Screenshots enik256 Linux - Newbie 5 03-02-2005 08:48 AM


All times are GMT -5. The time now is 07:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration