LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 06-28-2012, 10:42 AM   #1
udiubu
Member
 
Registered: Oct 2011
Posts: 54

Rep: Reputation: Disabled
insert prompt command


Dear all,

I have a shell script that produces some certain txt files according to the input.txt file I give in. So far, I insert every time the new input.txt filename into the shell, save the script and run it:

awk .... input.txt > output.txt

Is there a way to make the script asking me to write down which input file I would like to use?

Any suggestions, or references, would be highly appreciated!

Have a nice day,

Udiubu
 
Old 06-28-2012, 11:10 AM   #2
montel
Member
 
Registered: Jun 2012
Location: Canada
Distribution: Ubuntu/Debian/CentOS
Posts: 45

Rep: Reputation: 18
You can use the read command

Code:
echo "what is the name of the input text file?"
read in

awk... $in > output.txt
 
Old 06-28-2012, 11:22 AM   #3
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You can also pass command line arguments to the script. Look at this. Specifically, you want "4. Introduction to Variables and Parameters", then go to section 4.4 and look for "Positional parameters". The whole guide is good, in general.
 
1 members found this post helpful.
Old 07-03-2012, 10:20 AM   #4
udiubu
Member
 
Registered: Oct 2011
Posts: 54

Original Poster
Rep: Reputation: Disabled
Thanks to both of you!

Best,

Udiubu
 
Old 07-03-2012, 10:43 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
It would've helped more if you'd posted the actual script (or at least relevant parts of it). We'd likely be able to give you specific fixes.


BTW, assuming it's a bash script, try adding the "-e" option to read. This will enable all the readline editing functions, including tab completion. It makes entering filenames much easier.
 
  


Reply

Tags
input, prompt, text processing


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setup command not found in Ubuntu 10.04 Command Prompt vinaytp Ubuntu 2 05-06-2010 01:10 PM
'file' command for Windows/command prompt? SlowCoder General 4 06-16-2009 08:11 AM
startx command in FC7 reverts me back to the command prompt sriram87 Linux - Newbie 5 01-03-2008 11:18 PM
PostgreSQL insert command djgerbavore Programming 9 02-01-2005 07:27 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM


All times are GMT -5. The time now is 02:25 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