How and What should I read/study to can resolve this script?
Hello everyone,
I am a newbie on the world Shell Script. I just can build some scripts basically with the command which I used on the terminal. With the part algorithmic I don't have problem, but some functionality I can't and didn't know how around the situation.
I have the file .txt with more a less 800 000 lines with this structure:
Which I need to do?
Create an array with called "values";
Read the file .txt and import the data on each line (all line) for to index the array called "values";
The array called "values" will have another array, called "info_line";
In the index, about array called "info_line", will be placed which was after last slash "/";
The value this last array, "info_line", will receive which be between characters [...] - e.g. 6.0K;
Basically I new create a multidimensionally array.
The part which I don't know is "read the lines inside the file .txt" - collect exactly line by line. Collect the value which be after last slash "/".
I appreciate the guidance about how and what I should read an study for I can do this functionality. I have been reading about regular express, I think this is very useful to do this kind of jobs, am I correct?
I apologize about my level English, but if I can't explained the problem please tell me which I will try to explain the best I could. Thanks
I'm still not quite sure what you request. But, mayhap this script (needs a recent bash; unfortunately you don't mention your OS nor shell version) comes close to what you want:
As you can see, it has its weaknesses (e.g. for single item lines), and no error checking, but it may point you in the right direction...
Last edited by RudiC; 05-18-2016 at 07:12 PM..
Reason: typo
Well, it's difficult to say what to read and study in this case. Regexes were not used at all in above. As it was done in pure shell, man bash is the document to read, and to exercise. Read these fora to learn how to use it (and other tools) and to pick up the tricks.
Dear all ,
Very recently our DNS server ip got changed. I have entered the DNS ip in /etc/resolv.conf ...but I could not resolv it for my ip address.
Verified that , the IP is added in the DNS also.
It is still working with the old DNS ip.
Please let me know what could be... (11 Replies)
Hello everyone,
I have written a one liner which looks in a configuration file for remote hosts to connect to. It then resolves them by first ping, and nslookup if it fails, then places the info in the hosts file.
The whole thing works, seemingly, apart from one slight issue. I would like to... (0 Replies)
I am tyring to resolve an environment variable that is part of a string I selected from our database.
Simply put, I want cd to this folder before checking if a file exists.
The variable $in_loc has the value '$PS_HOME/int/VSP' where $PS_HOME is the environment variable.
I am using cd... (6 Replies)
Dear Members,
Please help me to resolve below script. The script is used to send the attachment in the mail with all the details. However in one of the incidents, the attachment in the mail was blank. Now the client is after me to get it resolved ASAP. So prompt response would be highly... (2 Replies)
#!/bin/sh# 'clear'for i in $(seq -w 15 37)doecho $iecho The content in ZZ=`wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.co.../test/test.jsp`echo $ZA="Connection timed out."echo The content in Aecho $Aexpr "$A" : '..\(...\)'echo $Adone
Hi,Please see the above program.
The above... (9 Replies)
#!/bin/sh
# 'clear'
for i in $(seq -w 15 37)
do
echo $i
echo The content in Z
Z=`wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.com:8000/webcore/test/test.jsp`
echo $Z
A="Connection timed out."
echo The content in A
echo $A
expr "$A" : '..\(...\)'
echo $A
done
... (1 Reply)
Hi
I have a variable which is a path ie:
UBERROR=/cobwrk/mchr/prodsup/ub/wrk/../error
is there anyway I can get the output of an echo to read:
#echo $UBERROR
/cobwrk/mchr/prodsup/ub/error
instead of
#echo $UBERROR
/cobwrk/mchr/prodsup/ub/wrk/../error
Many thanks! (2 Replies)
I am running LexMark MarkNetPro-3 print servers on my AIX network. All of the sudden, none of my printers will print anymore. I am getting an error message on the console:
Unable to resolve host name.
This message comes up everytime a user submits a print job.
Any Ideas? (1 Reply)