LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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


Reply
  Search this Thread
Old 08-16-2009, 08:09 AM   #1
jayant4285@gmail.com
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Taking the value from user


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{
}
 
Old 08-16-2009, 09:40 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,927
Blog Entries: 45

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Welcome to LQ!

I smell homework here?

Please read the LQ rules.
 
Old 08-16-2009, 10:06 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 10:07 AM.
 
Old 08-16-2009, 10:36 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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?
 
Old 08-16-2009, 12:46 PM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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?
 
  


Reply

Tags
from, user, value



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 04:42 AM
[ruby with emacs] taking user input lilili Programming 2 01-18-2007 12:17 PM
Why I'm taking the plunge tanstaafl4y LinuxQuestions.org Member Intro 2 10-30-2006 12:33 PM
Taking my first steps. ellion Linux - Newbie 4 05-11-2006 01:13 AM
Taking Screenshots enik256 Linux - Newbie 5 03-02-2005 07:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
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
Twitter: @linuxquestions
Open Source Consulting | Domain Registration