Script to read command line input and change it to some form


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to read command line input and change it to some form
# 1  
Old 07-22-2013
Script to read command line input and change it to some form

Hi,

I want to write a small code in which script changes command line input to some form.
Example

Code:
script.sh a1 a2 a3 a4 .....

output should be "a1|a2|a3|....."

Number of inputs in command line can be any variable


Last edited by Scott; 07-22-2013 at 12:36 PM.. Reason: CODE tags NOT ICODE tags
# 2  
Old 07-22-2013
Very easy:

Code:
#!/bin/sh

IFS="|"
echo "$*"

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 07-22-2013
Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error to Read Input from command line

Team , I am trying to write a case condition for database backups.But I am unable to make the script to read input from command line . while true ;do read -p "Do You Wish To Take Database Backup ?? " yn case $yn in *) echo " YES take backup ";; *) echo " NO BACKUP " ;; ... (9 Replies)
Discussion started by: rocking77
9 Replies

2. UNIX for Dummies Questions & Answers

How to submit form on an php webpage from command line?

Hello, i have page domain.com/form.php the form fields on form.php are named: name=ipaddress name=port and submit button is named: submit i want to ask how the linux command will look like to submit the form filled with: ipaddress: 127.0.0.1 port: 80 I tried various curl and... (5 Replies)
Discussion started by: postcd
5 Replies

3. Shell Programming and Scripting

Read input file with in awk script not through command line

Hi All, Do we know how to read input file within awk script and send output toanother log file. All this needs to be in awk script, not in command line. I am running this awk through crontab. Cat my.awk #!/bin/awk -f function test(var){ some code} { } END { print"test code" } (5 Replies)
Discussion started by: random_thoughts
5 Replies

4. Shell Programming and Scripting

Passing the value of variable which is read from command line in called script

Hi, I am calling a Perl script in my shell script. When Perl script is executed it asks for a answer to be entered by user from terminal. How can i pass that value from my shell script ?? I know I can change perl script to default the answer but i dont have access to do that so only option i... (5 Replies)
Discussion started by: varun22486
5 Replies

5. Shell Programming and Scripting

Shell script to input as if from command line to the java program

Hi, We are having a java server which can run on command line and once initiated, it will prompt options to enter from 0 to 5. The java program kickoff respective operation once number is entered between 0 to 5. However i want to always enter "1" and write another shell program wrapper to start... (4 Replies)
Discussion started by: surya5kn
4 Replies

6. UNIX for Dummies Questions & Answers

Bash script to delete file input on command line

1) I wrote a script and gave the desired permissions using "chmod 755 scriptname". Now if i edit the script file, why do i need to set the permission again? Didn't i set the permission attribute.. or if i edit the file, does the inode number of file changes? 2) I am running my unix on a server... (1 Reply)
Discussion started by: animesharma
1 Replies

7. Shell Programming and Scripting

How to read one character form each line of the file?

Hi, Maybe this iscorrect forum for my question... I should read one character at a fixed position from each line of the file. So how ??? should be substituted in the code below: while read line ; do single_char=`???` echo "$single_char" done < $input_file OK...I did get an... (0 Replies)
Discussion started by: arsii
0 Replies

8. Shell Programming and Scripting

sed to read line by line and input into another file

I have two files. Fileone contains text string one text string two text string three Filetwo contains Name: Address: Summary: Name: Address: Summary: Name: Address: Summary: I would like to use sed to read each line of file one and put it at the end of the summary line of file... (3 Replies)
Discussion started by: dolacap
3 Replies

9. Shell Programming and Scripting

How can I send the input of a read line command through a shell script

Hi All, I wish to automate the unix command 'su' through a shell script. I would like to pass the content of a file as password to 'su' command. My script is as below, #! /bin/sh su userA while read line do rpm -ivh $line done < pwd.txt where pwd.txt contains the password of... (6 Replies)
Discussion started by: little_wonder
6 Replies

10. Shell Programming and Scripting

read a file as input and pass each line to another script

Hi, I am trying to write a ftp script which will read a file for filenames and ftp those files to another server. Here's my ftp script, but it's scanning the current directory for file names. My question is how can I pass multiple files (these files will have the name of data files that need to... (0 Replies)
Discussion started by: sajjad02
0 Replies
Login or Register to Ask a Question