Programming :: Iterate The Content Of A File In The Shell Script?
May 29, 2010
i need to check group of URLs and there https requests from browser. Recently i got some command line web browsers to know the HTTPS status of the URL like curl, wget etc... Now all of i need to do is write a shell script. I will put all my URLs in a text file and my shell script should read each URL one by one and log the status along with the corresponding URL.
This is an slice from an other wise successful script. What i need it to do is print one <tr> then print <td>$stat_array</td> fours times, quit print a </tr> then print another <tr> , prints the next four $stat_arrays in @stat_array, and so on and then a </table>.What it does is print all eight $start_arrays then a </tr>
My employer issues pdf files with everyones work schedules. I copy the content and save it as plain text in a file called unformatted (hope to be able to automate this step someday). Im working on a SED script that reduces unformatted to only display what I want to see and saves the result in a file Iïve named formatted. After that I have to manually copy formatted and save it with that days date as a filename e.g. 2011-02-25 or whatever day is scheduled in the pdf, for use on a mobile device (Nokia N900). I noticed that the date occurs on certain lines in the file so I added a line like:
sed -n 's/^Date: (201[1-9])/([0-1][0-9])/([0-3][0-9]).*/1-2-3/p' < unformatted >theDate That creates a file theDate with the date in it that I wish to use as the filename for this particular instance. So I would like to skip the file formatted all together and have the sed- script write to a new file using the content of the Date as a filename, but how do I make that happen? And of course it would be more elegant if I could skip the intermediate theDate file as well.
go about developing this add-on. i am testing this on my xbmc-live set-up; i am fairly affluent in bash/ c but unfortunately i dont have experience with python.i trimmed the data using this bash 1-liner so the output looks like:
I a csv-file (A.csv) with a total of 4.600.000 lines. Thats to many and only a few is necessary. I have a txt-file with 150 lines (X.txt) (all lines is dataset from a mainframe and looks like abc.def.123.456. How do I remove lines from A.csv where none of the dataset from x.txt is present?
How can I write to a file multiple times using fwrite without affecting the previous writes?The method shown below accepts a file name, buffer and offset. The method opens the file in reading/writing mode and writes the content of the buffer at offset.
I'm woring on a personal research project and would like to know if there are lilypond parsers for python available or I'll have to create my own. Just in case you are wondering: I don't need to typeset the content of the lilypond file, just understand what's written in the file (what notes, what duration, when in time to play each one, etc). [url]
If you have the value 100 in File1 and the value 5 in File2, how do you write a script to divide the 100 in File1 by the 5 in File2 in Linux Bash Shell?The operating system I am using is Ubuntu 10 and object is to write a script to accomplish this task.
i want to close the program if the content of the file /tmp/file_name is 1 (just the number 1).
dont need to check all the time, just when start the program.
something like this:
Code: "read the /tmp/file_name" "check if the content of the file_name is 1" "if not, do something"
what i need is very simple to do in shell script:
Code: go=`cat /tmp/file_test` # "cat /tmp/file_test" read the content of the file_test if [ "$go" -eq "1" ]; then # if the content of the file_test is 1 echo "ok, ready to exit now"; # now i can put the exit command fi
I am trying to execute a 4GE file using command something like this "/usr/bin/ksh path of the file with some arguments " ex: /usr/bin/ksh /home/abc.4ge S "./xyz" . I am able to execute the 4GE without this "/usr/bin/ksh" specifying in the command which basically runs in ksh shell itself. But when i try to run it exclusively using the path of the shell it gives me an error something like this "/usr/bin/ksh: /home/abc.4ge: cannot execute". I did check the permissions and all the file has execute permission.
I have a file that's supposed to be growing in size 24/7. I want to check every 10 minutes via cron that it's actually growing. If not, send an email. Does anyone know how to write a script to do that?
I am beginner in this business of shell script and I have no idea how to do the following: I would like to replace the lines of my file that contains 'CFL=' by 'CFL=0.5'. Note that I want to replace the full line meaning
-Qjackctl has a config file which is modified each time QjackCtl is shut down. This means that whatever preset is in use when QjackCtl closes is written into the QjackCtl config file as the DEFAULT PRESET, for the next time QjackCtl starts (or at least this is how I understand it).
-I want to edit a specific line in the QjackCtl.config file, which specifies the DEFAULT PRESET. Obviously its easy to do manually, but I want to do it using a shell script which runs automatically on StartUp so that QjackCtl starts every time with the same DEFAULT PRESET, NOT the last one used.
-Unfortunately Im not at my Linux system right now (which is KXStudio/Kubuntu), but I believe the QjackCtl.config line looks something like this: DEF_PRESET=alsa (where alsa is the name of the preset)
I want a shell script which changes the line DEF_PRESET=alsa to DEF_PRESET=alsa, even when it may currently exist as DEF_PRESET=firewire due to occasions when firewire was the active preset when Qjackctl was last closed. I notice that the application in KDE that enables the user to set which applications open automatically on StartUp also allows the user to select shell scripts.
Ive done some research, as a beginner, and Im led to believe I might need to use AWK and/or CHMOD. I could have a go at writing a shell script but Im always wary about experimenting with StartUp scripts/operations because obviously if I get it wrong and make my system unusable, then because its going to run first thing on each boot, Id have great difficulty disabling it.
I am a novice to the shell script. In my system from db server the log files are enerating with the name log1.txt,log2.txt..... It is capable of keeping 10 files at a time in dir called /db/sis/log1.txt. I want to copy the log1.txt to another directory when ever it generating by attaching the time stamp to it for the back-up purpose. this files will be there for a period of 24 hours. after that the back-up dir should be cleared and it start copying again the fresh file from the same dir.
I'm writing a script and I have doubts on how to assign values to an already established variable. The value for the vatriable would be coming from a file with three columns. I'm using the awk command for this. Am I doing it correctly? which of the following two ways is the better one or if both are wrong which one should I use?