I am a beginner when it comes to writing scripts in LINUX so please bear with me when it comes to the question as it is probably a very simple issue.
I am just using some free time to write some LINUX scripts and have just worked ona very basic program that allows a user to input their name and then enter their top ten films. The user input is then written to a file using the following command :
echo "$input1,$input2.....etc" >> filename
In the output file the data is stored as below
input1,input2,etc
I am trying to find the right code to be able to assign the data from the output file to indiviual variables when reading from the output file. As there are liking to be spaces seperating word in the film title the only thing that is unique to seperate each instance is the ,
Is there some coding that I can use to complete this operation??
Sorry if the wording is not completely friendly but like I said I'm a beginner here so trying to do my best lol
To be honest, this sounds suspiciously like homework (which isn't allowed in this forum and for which there is a special place).
I will give you a pointer, but then close this thread because of this suspicion - sorry if i'm wrong, but we had a lot of students being dishonest about their homework.
To split a string at a delimiter into pieces you can use "cut". See "man cut" for details.
For instance: lets split "a bc de fgh" by the delimiter "space":
You can assign the output of a command to a variable using:
If you wrap double quotes around it it will even protect whitespace:
This should enable you to finish the script. I hope this helps.
So I'm stumped.
First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes.
I have a text file (file_source) of terms, each line... (3 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (4 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (1 Reply)
Hello,
I am new to Linux and have a general question.
In linux and unix you can have CGI scripts. I am aware of CGI as Computer Generated Images in graphics and Common Gateway Interface, but what are CGI scripts in relation to Linux or Unix?
Are CGI's in Linux and Unix relevant to only... (1 Reply)
Hello,
I am interested in finding out whether someone has a perl or awk script which takes a set of letters such as wak and referring to a dictionary spews out all possible forms such as awk, kaw etc.
If someone has such a script, could it be put up please. The script should handle Unicode.
Many... (0 Replies)
Hi All
I have written the following script:
#!/bin/ksh
while read cmdline
do
echo `$cmdline`
pid="$cmdline"
done<commands.txt
===========
commands.txt contains:
ps -ef | grep abc | grep xyz |awk '{print $2};
My objective is to store the o/p of the command in a variable and do... (8 Replies)
Need to develop a unix shell script for the below requirement and I need your assistance:
1) search for file.log and file.bad file in a directory and read them
2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file
4) concatinate each row from bad file as... (3 Replies)
Hi Gurus,
I am having an requirement. i have to read a list file which contains file names and send mail to different users based on the files in the list file.
eg. if file a.txt exists then send a mail to a@a.com
simillary for b.txt,c.txt etc.
Thanks for your help,
Nimu (6 Replies)
Hi
How can i dynamically read files names from a list file and execute them from a single shell script.
Please help its urgent
Thanks in Advance (4 Replies)