Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Get the input from user and save it as .txt file

Shell Programming and Scripting

input from user and save it as .txt

Thread Tools Search this Thread Display Modes
Old Unix and Linux 07-10-2013
Padmanabhan Padmanabhan is offline
Registered User
Join Date: Feb 2013
Last Activity: 12 September 2013, 7:05 AM EDT
Posts: 20
Thanks: 3
Thanked 0 Times in 0 Posts
Get the input from user and save it as .txt file

Hi friends,

I am pretty new to shell scripting, please help me in this Scenario.

for example, If I have one file called input.txt

once I run the script,

1.It has to delete the old input.txt and create the new input.txt (if old input.txt is not there, no offence, just it has to create a new one)

2. User has to paste the IDs (multiple line IDs) in the input.txt as a input.

3. once User Enter the input, it has to save the input.txt.

please help me in that. Thanks in advance. SDorry for my English
Sponsored Links
Old Unix and Linux 07-10-2013
zaxxon's Unix or Linux Image
zaxxon zaxxon is offline Forum Staff  
code tag tagger
Join Date: Sep 2007
Last Activity: 22 September 2017, 9:14 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,572
Thanks: 175
Thanked 560 Times in 481 Posts
  • Just overwrite the old file with a redirection like echo "" > input.txt
  • Read input with a prompt can be achieved with read. Else could use positional shell parameters of the shell like $1, $2, ...
  • For writing input.txt, redirect as said.

Try it, show your efforts. Ask if you get stuck showing your code.
According to your code in post http://www.unix.com/shell-programmin...only-once.html you should be able to get a start going.
Sponsored Links
Old Unix and Linux 07-10-2013
Subbeh Subbeh is offline
Registered User
Join Date: May 2011
Last Activity: 6 February 2017, 6:40 PM EST
Posts: 332
Thanks: 37
Thanked 87 Times in 86 Posts

cat > file

Then paste the ID's and press ctrl-d when finished,
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Open Text file input data and save it. asavaliya Shell Programming and Scripting 1 08-08-2012 04:24 PM
Pattern search and save it as .txt file with some name.. j_panky Shell Programming and Scripting 15 07-19-2011 09:27 AM
How to add data from 2 input files and save it in 1 output file redse171 Shell Programming and Scripting 4 12-15-2010 11:57 PM
Save Excel file as .txt in UNIX format jroyalty UNIX for Dummies Questions & Answers 2 04-08-2009 02:46 PM

All times are GMT -4. The time now is 06:27 PM.