General :: Breaking Iteration After A Given Number Of Iterations (bash)?
Jun 14, 2011
Take this block of pseudocode:
Code:
for i in $list; do
<some statements>
if i > 5
exit
<more statements>
done
That is, want to terminate the iteration just after 5 iterations. A first problem, is that list is a string and not a number. It's all I can say, except to keep reading bash monster manual.
View 8 Replies
ADVERTISEMENT
Jan 13, 2011
I'm trying to get an output of a file in numeric order. Basically I need the starting number and the ending number in sed this into anther file. The test2.lis file I'm just awk'ing for the first row and if its out of order put it in order so I can grab the first and last numbers. I'm sure I can do this all in an array. The first sed command gets rid of blank lines and outputs it to a file. Then I head and tail for the first and last number then I want to sed those numbers into a file that exsist.
[code]...
The error I get is:
sed: -e expression #1, char 24: unterminated `s' command.
View 13 Replies
View Related
Mar 17, 2011
I've these path:
Code:
xxx/yyy/zzz/0908/aaa/a.txt
xxx/yyy/zzz/0909/aaa/a.txt
xxx/yyy/zzz/0910/aaa/a.txt
fff/ggg/hhh/iii/jjj/0911/aaa/a.txt
fff/ggg/hhh/kkk/0912/aaa/a.txt
and I would like to extract only the number, so that I've get the result
Code:
0908
0909
0910
0911
0911
How can I do it in bash?
View 1 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Jul 29, 2010
My script is not diaplying output as it contains awk while iterating over the array. My script is as follows:
shortcodes=( "56882" "58585" "58888" "57575" "57677" );
for shortcode in ${shortcodes[@]}
do
echo "`awk -F"|" '/ShortCode=tel:$shortcode/ { arr[substr($2,1,4)]++ } END { for( no in arr) { print no , arr[no] } }'
[code]....
View 4 Replies
View Related
Aug 2, 2010
I have a file in the form below, and wish to replace each start line with an increasing number. So instead of:
Code:
start
content content
start
content content
start
[Code]....
After several searches and a bit of messing around, it's clear I'm missing something, so was wondering if anyone could offer any insight?
View 17 Replies
View Related
May 22, 2010
Code:
tupe=("File",("Open","Open a file"),"Edit",("Cut","Cut a file"),("Paste","Paste a file"),"About",("About","About the program"))
menutitle=""
menupos=0
for items in tupe:
if type(items)==str:
[Code]...
I'm trying to understand how to make "File" be the parent information for "Open","Open a file" and "Edit" to be the parent of "Cut, Cut a file" and "Paste", "paste a file". Does anyone have a suggestion for accessing the a nested tuple in this manner? The above code does not quite do what I want it to. The above code is for visual purposes, but I'm learning how to refactor for wx.python.
View 3 Replies
View Related
May 15, 2011
How can i get bc to subtract negative numbers?
View 10 Replies
View Related
Oct 14, 2010
How to break strings of command into multi-lines in crontab? e.g.
Code:
# the following is a very long a gruesome command to be run at 09:59 Monday to Friday.
59 09 * * 1-5 source $HOME/some-definitions; sh /usr/local/my/long/name/application/bin/hello $(date +\%Y\%m\%d) >>/var/log/my/long/name/application/log/hello.log
View 2 Replies
View Related
Dec 2, 2009
I want to make a very simple bash script to run a command for a user-specified number of seconds and then kill it. The purpose is to limit the amount of time the program runs.Example in pusedocode:
Code:
#!/bin/bash
#$1 is the user input number of seconds
[code]...
View 14 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 2 Replies
View Related
Jul 1, 2010
Is there a way to count the number of errors- an exit variable $? from one function?
The output from the exit variable (either erroneous or correct (1) or (0)) is it possible to add the erroneous one ups?
View 3 Replies
View Related
Oct 24, 2010
One of my servers needs to issue an "apt-get update" command on each of the clients in a lab. However, after the first update, it exits. In trying to replicate the problem with a simpler script, I created the following which fetches the listings of multiple directories from a client:
NUM=0
cat paths | while read DIR; do
ssh server-name ls $DIR > /tmp/$NUM.txt
NUM=`expr $NUM + 1`
done
Again, after the first iteration, the script exists. I tried the following line too, but it made no difference:
bash -c ssh server-name ls $DIR > /tmp/$NUM.txt
The only thing that worked so far is this
xterm -e ssh server-name ls $DIR > /tmp/$NUM.txt
View 3 Replies
View Related
Aug 9, 2010
I have the following code in bash script:
Code:
#!/bin/bash
COUNT=1
# bash until loop
until [$COUNT -gt 2]; do
pq A$COUNT [Pemptus].pq &
let COUNT=COUNT+1
done
I did this because I'm that much of a Progress Quest geek that I wanted to have a huge group on the online server, so I decided to make a script that would open all the files for me rather than having me do it manually. I created some characters with the boring name of A1, A2, etc. When I ran the above script, it went into a continuous loop and I had to halt it, then run sudo killall pq.exe to eliminate the 500 or so Progress Quest windows that popped open. Anyway, what is wrong with my script that I can't seem to get it to stop loading files at an arbitrary number? I want to get this part finished before I make any more boring named characters.
View 1 Replies
View Related
Jan 29, 2010
I have no Bash skills but Im badly in need of a script to move the first 20,000 or whatever number of files from a directory containing over 200,000 files to a new directory. The problem is that I cant access the directory because its so large so I want to break it into chunks, but keep the files in order if possible. If you know of a script to meet my needs, please post it. Otherwise Ill post my fumblings with Bash until I find the right way to fix my problem.
View 14 Replies
View Related
Sep 18, 2010
I want to move files from a $SOURCEDIR to a $DESTBASE/$DESTDIR. Under $DESTBASE there are many directories, and I need to test beforehand if a file from $SOURCEDIR already exists in any of them.
This is obviously extremely slow, and the real use case involves dozens of dirs and thousands of files. Creating a temporary "index" file for the find command (instead of running it every iteration) speeds it up a little, but it's still very clumsy.
View 14 Replies
View Related
Aug 11, 2010
I would like to parse an input file in which there are two columns per each row. We want to see how many lines are duplicated where we define duplicate to be having the same second field and different first field. For instance if the input file looks like the following:
79874 13131
79873 12309
79820 13131
[code]...
View 10 Replies
View Related
May 21, 2011
Why does unix ps -l whows one number in column "PRI" but in same time ps -o pri shows another number? cpu and nice are zero for those processes
View 1 Replies
View Related
Feb 27, 2010
I have a string problem with a function I am writing and I cant figure it out. I am trying to write unit test which will verify it works as expected. As I need to make use of it elsewhere and obviously robust and correct enough that I can rely on it. Okay first of all I define the following structure
Code:
typedef struct strarray {
int size;
char **elements;
} strarray;
code....
My problem is that upon the 4th iteration in the loop realloc fails in strarray_add. glibc reports invalid next size.
View 6 Replies
View Related
Jan 4, 2011
I tried the steps usually offered (modifying the grub.cfg file, replacing the wubildr files), it still wouldn't boot.
I booted in with the LiveCD to try to chroot into the environment and try running 'update-grub'. However, whenever I tried to chroot, it said it could not execute /bin/bash!
Trying to modify the grub commands manually (which originally gave the error: you need to load the kernal first), in the end said "invalid magic number"
There are some configuration things set in this installation I would like to not lose. Is it hopeless?
View 6 Replies
View Related
Jan 9, 2010
The problem is: after i typed: cat </dev/urandom (i think it inserted a controll character where i cant find it)at my bash prompt (sh and python are fine) and only once per prompt before the line should break it just starts at the beginning of the same line and overwrites itsself (only on the screen its interpreted as typed) .This really bugs me because i love working with bash and i don't want to reinstall the system.I tryed reinstalling bash and readline without success.is there any config files i could check? my PS1=e[44m[e]0;u@h: wa]${debian_chroot:+($debian_chroot)}u@h:w$ e[0m
View 3 Replies
View Related
Jun 14, 2010
Why krunner keeps breaking? Sometimes it runs, sometimes it doesn't.
Here's the error message.
Code:
View 2 Replies
View Related
May 10, 2011
I started using 10.10 a few months ago and had very few problems aside from a few minor issues with Wine. I frequently used Skype under 10.10 and it ran perfectly with no issues whatsoever.
Recently I upgraded to Ubuntu 11.04 and well... basically things have just gone downhill from there.
Over the past few days Skype has been ridiculously unstable, I'll be talking to somebody using text chat and it will essentially freeze up. These freezes can occur within minutes of starting Skype and are very infuriating. I am still able to type and send messages but the "message not sent" icon will appear next to each of them and the timestamp on each message will be identical (the messages in question will not send even after a restart of Skype). This problem will persist until I force-quit the application, closing it normally will not work and often I have to restart my computer entirely before it will work again.
I have tried updating to the latest version of Skype to no avail (if anything I think it has made matters worse, but that may just be my imagination.)
I'm not particularly command savvy, just posting on the off chance that anybody has encountered the same problem or has found a relatively simple fix. I don't really want to have to re-install the entire OS just to roll back to 10.10.
View 9 Replies
View Related
May 24, 2011
Is there a way to uninstall all the bloat without breaking ubuntu? It seems like some things (banshee, the calendar, ubuntu one) are integrated with the notifcations and probably other areas too. I think last time I uninstalled them, the calendar was still there in the notifications but clicking a date did nothing, and I'm sure there were other leftover goodies that I didn't take time to find before re-fresh-installing ubuntu. I think ubuntu has a lot of potential as a linux distro, but I'm not interested in their promoted software (i.e. libreoffice)
Another question: when you install an application in windows and then uninstall it, there remain uninstalled changes to your system (leftover icons, links, shortcuts, folders, files, registry entries) like the uninstaller was drunk on the job. Is this fixed in ubuntu or are there remnants of everything you uninstall?Also comments welcome on what you consider both bloat and safe to uninstall.
View 9 Replies
View Related
Nov 8, 2015
When I boot my debian desktop, I get these errors:
Code: Select allnov 08 22:05:12 Luca-PC systemd[1]: Job paths.target/start deleted to break ordering cycle starting with basic.target/start
nov 08 22:05:12 Luca-PC systemd[1]: Job rpcbind.service/start deleted to break ordering cycle starting with basic.target/start
nov 08 22:05:15 Luca-PC systemd[1]: Job paths.target/start deleted to break ordering cycle starting with basic.target/start
nov 08 22:05:15 Luca-PC systemd[1]: Job sysinit.target/start deleted to break ordering cycle starting with basic.target/start
nov 08 22:05:15 Luca-PC systemd[1]: Job rpcbind.service/start deleted to break ordering cycle starting with sysinit.target/start
The system works perfectly, but I'd like to understand why I get these errors, and how I can fix them.
View 4 Replies
View Related
Jul 9, 2010
On my Sid box, I did an update and it appears it also updates udev's rule set that doesn't like the notion of dm-crypt or LVM. For example:
Code:
trilarian@Debian-Desktop:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-1 9.9G 2.4G 7.1G 26% /
tmpfs 438M 0 438M 0% /lib/init/rw
udev 10M 192K 9.9M 2% /dev
tmpfs 438M 0 438M 0% /dev/shm
/dev/md0 94M 83M 12M 88% /boot
/dev/dm-2 1008M 630M 328M 66% /var
/dev/dm-3 600G 291G 310G 49% /home
When I used to run df I would get lvm/dm name instead of number, like:
Code:
/dev/mapper/raid-root 9.9G 2.4G 7.1G 26% /
What I need to change in udev to restore the old function?
View 1 Replies
View Related
Jan 31, 2010
Is there an easy way to Remove a package and all packages it depends on without breaking other packages?
View 2 Replies
View Related
Sep 20, 2010
I've only gone into the first case statement of the first switch and I am trying to get out of it but the break statement I added doesn't seem to have any effect and it just goes on to the next case instead of exiting the switch.
Code:
import java.util.*;
import javax.swing.*;
public class A2 {
public static void main(String[] args) {
double gross_Pay;
int payment_Method;
final double salary_Pay = 1000.00;
final double hourly_Pay = 25.00;
double overtime1 = 20.00;
double overtime2 = 30.00; .....
View 2 Replies
View Related
Oct 10, 2010
my issue is that the when i put in the correct input its going into the loop like i put in incorrect input and wont break out of the loop even with the correct input entered
Code:
import java.util.*;
import javax.swing.*;
[code]...
View 3 Replies
View Related
Nov 29, 2010
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
View 6 Replies
View Related