LinuxQuestions.org
Help answer threads with 0 replies.
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: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,201
Blog Entries: 3

Rep: Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426Reputation: 1426
Hi,

Welcome to LQ!

I smell homework here?

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

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
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: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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,150

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 03:09 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration