Sponsored Content
Full Discussion: For loop to break apart word
Top Forums Shell Programming and Scripting For loop to break apart word Post 302778189 by elixir_sinari on Sunday 10th of March 2013 01:57:49 AM
Old 03-10-2013
Code:
word=excellency
i=0
len=${#word}
while ((i<${#word}))
do
 echo "${word:$i:2}"
 ((i+=2))
done

or a tweak to anbu23's solution:
Code:
# echo $1 $2 $3 $4 $5
echo "$@"


Last edited by elixir_sinari; 03-10-2013 at 04:11 AM..
This User Gave Thanks to elixir_sinari For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to break the while loop???(Very Urgent)

H, I am running the following log.sh shell script. $no_of_ps=7 while do echo "hello $no_of_ps" ps_file=`tail -$no_of_ps /tmp/A380_RFS24/test.ls | head -1` no_of_ps=`expr $no_of_ps - 1` echo "package is: $ps_file" >> /tmp/A380_RFS24/log/A380_RFS24.log ps_file1=`echo $ps_file| sed... (1 Reply)
Discussion started by: sunitachoudhury
1 Replies

2. Shell Programming and Scripting

Weird loop break,- please Help

Hi all, im doing this script in which i read from a logfile line by line, my problem is this: The script was working fine until i added this statement to SSH into another machine to look for some data, it enters and retrieves the data just fine, but for some strange reason after it goes thru the... (1 Reply)
Discussion started by: sx3v1l_1n51de
1 Replies

3. Shell Programming and Scripting

How to break a loop if condition is met

I am having trouble figuring this code I want to grep a text from a file and if it match certain text it break out of the loop or it should continue searching for the text Here is what I have written but it isn't working while true f=`grep 'END OF STATUS REPORT' filename` do if ... (9 Replies)
Discussion started by: Issemael
9 Replies

4. Shell Programming and Scripting

break while loop in BASH

Hi gurus, I have the following part of code which I am using for treating input #!/bin/bash while ]; do arg=$1; shift case $arg in -u) users="$1" shift ;; -g) groups="$1" shift ;; ... (4 Replies)
Discussion started by: wakatana
4 Replies

5. Shell Programming and Scripting

sed: break before word if it's not last on the line

I've been trying this, and can't get it right. I want to put a line break before a word, but only if it's *not* the last word in the line. So if the break work was "fish," then... We want to fish tomorrow ...would become... We want to fish tomorrow ...but this line would remain... (3 Replies)
Discussion started by: estebandido
3 Replies

6. Shell Programming and Scripting

break the string and print it in a new line after a specific word

Hi Gurus I am new to this forum.. I am using HP Unix OS. I have one single string in input file as shown below Abc123 | cde | fgh | ghik| lmno | Abc456 |one |two |three | four | Abc789 | five | Six | seven | eight | Abc098 | ........ I want to achive the result in a output file as shown... (3 Replies)
Discussion started by: kannansr621
3 Replies

7. Shell Programming and Scripting

Line break on word

I have a file that contains the following: ^field LINE_1 data ^field LINE_2 data ^field LINE_3 data ^field LINE_4 data ^field LINE_5 data ... And im looking to do a line break at the end of the number before the text to make it look like this ^field LINE_1 ... (11 Replies)
Discussion started by: darbs121
11 Replies

8. Shell Programming and Scripting

Break the outer loop

Hi I'm comparing same files names which are in different folders . The first for loop for the files in DAY1 folder and the second for loop for the files in DAY2 folder . the first IF condition is for checking whether the file names are equal the second If condtion is for checking the... (4 Replies)
Discussion started by: smile689
4 Replies

9. Shell Programming and Scripting

Basic FOR loop with break

Oracle Linux : 6.4/bash shell In the below I want to break out of the loop when it enters the 5th iteration. #!/bin/bash for i in 1 2 3 4 5 6 do echo "$i" if echo "Oh Nooo... i = $i. I need to stop the iteration and jump out of the loop" then break fi done But, it only... (3 Replies)
Discussion started by: John K
3 Replies

10. Shell Programming and Scripting

Break in for loop

in my python script i have loop like below: for item in itemlist: if <condition>: <code> else: <code> if <condition>: if <condition>: <code> else: for type in types: if... (1 Reply)
Discussion started by: ctrld
1 Replies
BOGGLE(6)							 BSD Games Manual							 BOGGLE(6)

NAME
boggle -- word search game SYNOPSIS
boggle [-bd] [-s seed] [-t time] [-w length] [+ [+]] [boardspec] DESCRIPTION
The object of boggle is to find as many words as possible on the Boggle board within the three minute time limit. A Boggle board is a four by four arrangement of Boggle cubes, each side of each cube displaying a letter of the alphabet or `qu'. Words are formed by finding a sequence of cubes (letters) that are in the game's dictionary. The (N+1)th cube in the word must be horizontally, vertically, or diagonally adjacent to the Nth cube. Cubes cannot be reused. Words consist solely of lower case letters and must be at least 3 letters long. Command line flags can be given to change the rules of the game. -b Run boggle in batch mode. A boardspec must also be given. The dictionary is read from stdin and a list of words appearing in boardspec is printed to stdout. -d Enable debugging output. -s seed Specify a seed seed other than the time of day. -t time Set the time limit for each game from the default 3 minutes to time seconds. -w length Change the minimum word length from 3 letters to length. + This flag allows a cube to be used multiple times, but not in succession. ++ This flag allows the same cubes to be considered adjacent to itself. boardspec A starting board position can be specified on the command line by listing the board left to right and top to bottom. Help is available during play by typing '?'. More detailed information on the game is given there. AUTHORS
Boggle is a trademark of Parker Brothers. Barry Brachman Dept. of Computer Science University of British Columbia BUGS
If there are a great many words in the cube the final display of the words may scroll off of the screen. (On a 25 line screen about 130 words can be displayed.) No word can contain a 'q' that is not immediately followed by a 'u'. When using the + or ++ options the display of words found in the board doesn't indicate reused cubes. The dictionary that NetBSD installs omits many words that belong in the English language, most notably inflected forms. BSD
September 23, 2006 BSD
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy