General :: Modify Loop Code (For And While) To Get Output Returned
Jul 20, 2010
Filename.txt
Code:
My First Line
My Second Line
::::While Loop:::
Program:
Code:
while read line
do
echo "$line"
done < Filename.txt
output:
Code:
My First Line
My Second Line
Is it possible to use for loop to get the same output. I have tried executing below code but I get every word of my file being displayed one below above.Is there any way I can modify the for loop code to get the output returned by while loop?
:::For Loop:::
Program:
Code:
for line in $(cat Filename.txt)
do
echo $line
done
output:
I am posting this just for the sake of curiosity. I am trying to feed a while loop structure with a command output, but using the bash built-in I get the error "ambiguous redirect":
Since I'm quite new to Linux I wonder what "Sub-process /usr/bin/dpkg returned an error code (1)" mean ?? Is it RTFM/read the damn logs at /var/log or does someone have an answer to this ?
When trying to install php5 I got the following result. Tried to apt-get clean, autoclean, remove --purge then reinstall the mentioned packages without any success.
dpkg --configure -a didn't get any better result.
Code: Select allsudo apt-get install php5 Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait Les paquets supplémentaires suivants seront installés : libapache2-mod-php5 php5-cli php5-common
I think that my computer crashed one time, while I was in middle of installing some new software, and it seems like it have made "dpkg" confused with itself - it thinks, that I still need to install "Wine", but it is allready installed, so everything is allright. But everytime, when I am upgrading or installing any kind of software, it give me this error (just an error, everything still works and installs fine):
I'm tried to install bandwidthd on Ubuntu 9.10 and keep getting the following error.I have been looking around for a while and have been unsuccessful in finding a answer.
HTML Code: $sudo apt-get install bandwidthd Reading package lists... Done
I'm trying to customize my BackTrack4 image so I can use the live disk with my ati graphic card. While trying to put the drivers with the apt-get install ati-driver command, I get the following message:
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: ati-driver
Thought I could just place a hard drive with a preloaded Ubuntu install from another machine (a loaner machine) into this one; change a few drivers and be on my way. Too many errors to count. ALSA; Jack; LiveTex all cratered and I'm tired of fighting this. I've spent more than two days trying to get stuff working and if there's anything I've learned from years of experience there's a time to cut bait and run.
A clean install on the actual hardware I'm using has to be better than the hodge podge I have now.What I would like from the community is recommendations for what to do AFTER the install.
1) where can I find the most up-to-date comprehensive and exhaustive list of repositories for the Synaptic Package Manager?
2) I like to do sound and video processing. I would like to have the program applications Qsynth, Virtual Midi Keyboard, Muse Score, Csound, GNU Denemo, and many others that either fail to start or produce no sound to work. What, besides the programs need to be loaded in order to make these work?
3) A helpful list of recommendations on what to install along with order preference. In other words 'this needs to be done before this...' on a new Ubuntu install.
In case anyone's interested: Here's a small list of some of the errors I currently have. AlsaModularSynth - Could not open file.Qsynth1 - Failed to create the audio driver (jack) / Jack server not running.
Errors were encountered while processing:
texlive-latex-base-doc E: Sub-process /usr/bin/dpkg returned an error code (1)
Qtractor - The audio/MIDI engine could not be started. Make sure the JACK audio server (jackd) and/or the ALSA Sequencer kernel module (snd-seq-midi) are up and running and then restart the session.
apt-get install alsa-utils - Errors were encountered while processing: texlive-latex-base-doc E: Sub-process /usr/bin/dpkg returned an error code (1)
Jack configuration files not found; the list is endless. Plus many errors trying to get texlive to work.
The problem emerged when I started to make the internal microphone and external speakers work [URL]. In either kernel 2.6.32-24 or 2.6.35-15 - cannot install any package with apt-get. Here is the error I get when installing just anything [URL]. Basically, here is it:
Code: ERROR: Build failed. Please review the build log at /tmp/alsa-driver-linuxant.3620.log dpkg: error processing alsa-driver-linuxant (--configure): subprocess installed post-installation script returned error exit status 2 Setting up libxslt1-dev (1.1.26-1ubuntu1) ... Errors were encountered while processing: alsa-driver-linuxant E: Sub-process /usr/bin/dpkg returned an error code (1)
I have a little home server running server 8.04 and decided to check for upgrades. One of the upgrades was a new kernal update. It was able to download the update, but errors on uncompressing it. I have even shutdown the server and restarted it. Still no luck.
Here is the screen log from the update process:
(Reading database ... 49993 files and directories currently installed.) Preparing to replace linux-image-2.6.24-28-server 2.6.24-28.80 (using .../linux- image-2.6.24-28-server_2.6.24-28.81_i386.deb) ... Done. Unpacking replacement linux-image-2.6.24-28-server ...
Iam trying to burn wave files to a cd that i ripped from a cd when i try burning to gets to 300 meg and stops with these errors CD RECORD RETURNED AN UNKNOWN ERROR (CODE 254) SOMETIMES USING TAO WRITING MODE SOLVES THIS ISSUE Using ubuntu 10.04
I read that passwd -S spits out informationabout a user's password including the encryption algorithm used to encrypt the password in /etc/shadow. I ran the command but nothing about the algorithm is returned. Is this a quirk in openSUSE?On another note, I've determined through other means that I've selected blowfishryption as evidenced by the $2blah$2blahblah format of the /etc/shadow entry. However, if I look at /etc/default/passwd it lists CRYPT=md5. If I'm using blowfish why would that variable be set to md5. onversely, if it is set to md5 why is the blowfish algorithm being invoked?
I'm trying to modify the code for gblink so that it can read from my usb to parallel port cable. I know that the address for a normal parallel port (/dev/lp0) is 0x3bc, but how can I find out the address for /dev/usb/lp0?
I read that xinetd listens on the service port and passes incoming traffic to the service (ftpd) via stdin. However, the ftpd source code reads its input from a socket not from stdin.
Am I to conclude that in order to be managed by xinetd, the source code for ftpd (or telnetd etc..) must be modified or recompiled to take its input from stdin??
The output of a command changed and I need to extract the data and print it out in a different fassion:
Code: abcd1=aaaa xx abcd 2 aaa xx bbb abcd2=aaaa xy ab 2 xx aaa bbb ccc xxx should be transformed to:
[Code]...
Currently I used sed "search1|search2|search3" to get the lines that need to be transformed. But I also need to search for substrings in those lines and I need to print those substrings in a specific order together with other characters. How is this done with sed?
I'm running RHEL5.5 and nagios 3.2.0. The real question deals with how to change the printed output so nagios will work with it.I have made a script that will calculate network throughput on interfaces. The script is going through and finding all interfaces (eth, bond, lan) and doing the math to calculate throughput.The output is mainly for nagios to report and trend the values. As nagios wants to see nothing but perf data after the '|' character, I somehow need to have only one '|' character for all of the output.
PU12829,24869;PD15733,24869;PD15733,19785;PD12829,19785;PD12829,24869; PU4599,20915;PD9924,20915;PD9924,18898;PD4599,18898;PD4599,20915; PU12829,24869;PD15733,24869;PD15733,19785;PD12829,19785;PD12829,24869; PU4599,20915;PD9924,20915;PD9924,18898;PD4599,18898;PD4599,20915; PU1723,3423; #this line is ignored to short
[Code]...
What I'm trying to do is while true, cut each line from file that begins with PU and thats longer than 12 characters and write to a increasing numbered file for each line. Stating with object1 etc.
simple scan error as follows: Failed to save file ImageMagick returned error code 11 Command line: convert -adjoin /tmp/simple-scan-DA9MBV.jpg /tmp/simple-scan-XCK4BV.jpg /tmp/simple-scan-NZVYBV.pdf Stdout: Stderr: using karmic note: I have apparmor extra profiles installed but didn't notice one that related to simple scan or imagemagick. Red herring or not?
I work in a simulations environment. I'm trying to write a bash script that will read fields from a .csv file into an array, the first field being an identifiyng number and the second field being a corresponding url. There are about 1600 of these number/url combinations in the .csv file that i'm reading from. Once that is done i want it to parse a text file and match the number, when it has a match i want it to enter the corresponding url into a particular line in the text file. The script I have written (with the help of the people on this forum a while back) does this well, but now I have a lot more data to parse. I think the script itself is explanatory enough to see what i'm doing. What i would like to do is cut it down to one while loop nested inside another loop so that I don't have 1600 or so elif statements. I can't figure out how to increment the output of the array. for instance, the first cycle would find the number that matches ${record1[2]} and input the url stored in ${record1[3]}. the next cycle would match ${record1[4]} and input the url in ${record1[5]}, and so on, does that make sense? The code is below and a sample .csv and text file are attached.
I have apache 2.2.3 installed with php5 and libapache2-mod-php5. The server displays web-pages fine, but when I try to load a .php file, nothing shows up. There aren't any errors, not in the browser and not in the Apache2 error logs... just nothing shows up. When I look at the page source on the browser, all the HTML code is there, but all the PHP code is gone, as though it was parsed. I can't get any output to show up though, echo and print both do nothing.What could be the problem?Example: