How to do I manipulate a variable in a do loop?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to do I manipulate a variable in a do loop?
# 8  
Old 02-20-2015
Have you read any of the posts in this thread. Is there anything you do not understand about these suggestions?
# 9  
Old 02-20-2015
Thanks RudiC, the first example works great.
# 10  
Old 02-20-2015
General definition of insanity:
Repeating the very same thing over and over and expecting diffrent results.

Increased chances if:
One is ignoring everything one is beeing told.
And simply keeping repeating the very same question over and over.
(saying: rephrasing your repeated question, maybe that will help)


Rather than stay focused on removing single characters, try the new approach - removing strings.

Have a nice and sunny friday Smilie

Last edited by sea; 02-20-2015 at 10:16 AM..
# 11  
Old 02-20-2015
Thanks Scrutinizer, this works great.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

2. Shell Programming and Scripting

While loop variable

while read -r tabname rem do select count(*) from $tabname" > /dev/null RC=$? if ] then echo "error on $tabname" >> error.out fi done well in above code i need the echo "error on $tabname" to come in separate o/p file which show the table name whc... (3 Replies)
Discussion started by: netdbaind
3 Replies

3. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

4. UNIX for Dummies Questions & Answers

Writing a for loop to manipulate multiple files

Hi, I have 1000 text files in a folder that are labeled data1.txt all the way to data1000.txt. I want to write a small script that manipulates the text files in this way: (1) cut the 2nd and 9th columns of the text files (2) sort by the numerical value in the 9th column (3) then save the rows... (3 Replies)
Discussion started by: evelibertine
3 Replies

5. UNIX for Dummies Questions & Answers

Loop and variable not exactly variable: what's wrong

Hello guys, This truly is a newbie question. I'm trying to make a loop to execute simultaneous commands indefinitely while using variable. Here is how my mess looks like (this is just an example): #!/bin/bash IP=`shuf -n 1 IP.txt` # I figured this would be easier to select random lines... (4 Replies)
Discussion started by: bobylapointe
4 Replies

6. Shell Programming and Scripting

printing variable with variable suffix through loop

I have a group of variables myLINEcnt1 - myLINEcnt10. I'm trying to printout the values using a for loop. I am at the head banging stage since i'm sure it has to be a basic syntax issue that i can't figure out. For myIPgrp in 1 2 3 4 5 6 7 8 9 10; do here i want to output the value of... (4 Replies)
Discussion started by: oly_r
4 Replies

7. Shell Programming and Scripting

[SHELL: /bin/sh] For loop using variable variable names

Simple enough problem I think, I just can't seem to get it right. The below doesn't work as intended, it's just a function defined in a much larger script: CheckValues() { for field in \ Group_ID \ Group_Title \ Rule_ID \ Rule_Severity \ ... (2 Replies)
Discussion started by: Vryali
2 Replies

8. UNIX for Dummies Questions & Answers

Writing a loop to manipulate a script and store it in multiple output files

I have a script where the the 9th line looks like this: $filename=sprintf("250.1chr%d.ped", $N); I want to modify this script 1000 times, changing 250.1chr%d.ped to 250.2chr%d.ped, 250.3chr%.ped.......and so on all the way to 250.1000chr%d.ped and store each output in files called ... (4 Replies)
Discussion started by: evelibertine
4 Replies

9. Shell Programming and Scripting

Variable changes after a loop

Hi, I am a beginner with shell programming: the code is following: #!/usr/bin/ksh v_res="start" echo "v_res_begin="$v_res grep -E "#FlatFiles" "a.log" | while IFS= read vLine do set -- $vLine v_res="error" # there is some code ... if error then break echo... (4 Replies)
Discussion started by: llelkes
4 Replies

10. Shell Programming and Scripting

variable in a for loop

Hi... i am trying to ping my servers .The hostnames are present in a file .They are separated by spaces in the file . i am doing the following : a=1 for name in $(cat host2 |cut -d" " -f$a) do echo Pinging server $name ping -c5 $name a=$a+1 done It is... (3 Replies)
Discussion started by: sars
3 Replies
Login or Register to Ask a Question