Need some advise on two for loops to display and to number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need some advise on two for loops to display and to number
# 8  
Old 09-25-2007
Print Line numbers

Hi there,

if your trying to simply print your file with numbers on each line try this:


#!/bin/bash

set -- $( cat inputfile )

while [ "$int" -le "$lineno" ]
do
eval line=$1
echo "$int ) $line" >> usernameoutput
int=$(( $int + 1 ))
shift
done

outputt is:

1 ) aaa
2 ) bbb
3 ) ccc
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Advise on how to print range of lines above and below a number?

Hi, I have attached an output file which is some kind of database file mapping. It is basically like an allocation mapping of a tablespace and its datafile/s. The output is generated by the SQL script that I found from 401 Authorization Required Excerpts of the file are as below: ... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

Display the last part of a number list

Hi , i have a file wich have 50+ of numbers like : 0.014544106 0.005464263 0.014526045 0.005484374 0.014539412 0.005467600 0.014558349 0.005452185 i would like to display the list from the 6th bit to the end for example 0.005452185 (should become) 2185. I've tried with ... (4 Replies)
Discussion started by: Board27
4 Replies

3. Shell Programming and Scripting

loop to display whatever number use types

sorry couldnt think of a proper title lol ok i have the following script it asks the user how many html tags they want. Im not sure how to display 2 tags if the user eneters the want only 2 tags tags as in <p></p> or <h1></h1> read -p "How many tags" tags1 if then echo "<$tags1>... (3 Replies)
Discussion started by: gangsta
3 Replies

4. Shell Programming and Scripting

problem with floating point number loops

Hey, I guess I am just to stupid and am not seeing the "wood for the trees", but I am always getting strange errors. I want to create a mesh with coordinates like: x y z 3.1 3.0 0.75 0 0 1 3.1 2.9 0.75 0 0 1 3.1 2.8 0.75 0 0 1 3.1 2.7 0.75 0 0 1 3.0 ... (10 Replies)
Discussion started by: ergy1983
10 Replies

5. Shell Programming and Scripting

display unique number

Hi, how i can display all the unique number from my random number script below; #!/usr/bin/perl use strict; my @alphanum = ( 'A' .. 'Z', 'a' .. 'z', 0 .. 9); my $random = join('', map($alphanum,(1..5))); print "$random\n"; Thank You. (1 Reply)
Discussion started by: malaysoul
1 Replies

6. Solaris

Display Serial Number

Hello, I am running Solaris 9 and I need to display the serial number of my machine. How can I do this? Here is my machine info: SunOS birch 5.9 Generic_118558-09 sun4u sparc SUNW,Sun-Fire-V240 Thank you, David (5 Replies)
Discussion started by: dkranes
5 Replies

7. Shell Programming and Scripting

display number of subdirectories

Can anyone tell me what command would display the number of subdirectories in the current or given location? (2 Replies)
Discussion started by: jjamd64
2 Replies

8. UNIX for Dummies Questions & Answers

how to display line number for tail -f

Hi, Just wonder if there is any quick way to display line number when monitoring a log file with tail -f? (4 Replies)
Discussion started by: iengca
4 Replies

9. Programming

how i display number in words

helo i want to implement the following concept in my project write a c/c++ algorithm for : accept a number from the user not greater than 6 digits and display the number in words i.e. if the input from the user is 18265 then the output should be Eighteen Thousand Two Hundred Sixty Five. if the... (3 Replies)
Discussion started by: amitpansuria
3 Replies

10. UNIX for Dummies Questions & Answers

How to use ps to display processor number

I'm on a Unix 5.2 server and I want to be able to see my processes to verify they are active and which processor they are running on. ps -l will show me the status of process (active/stopped/idle) but to see which processor the process is assigned to I don't know how. Manpages show -o... (1 Reply)
Discussion started by: tumblez
1 Replies
Login or Register to Ask a Question
LIBBASH(7)							  libbash Manual							LIBBASH(7)

NAME
libbash -- A bash shared libraries package. DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may want to load and use in scripts of your own. It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries. Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded using ldbash(1) must answer 4 requirments: 1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash). 2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library exports. I.e. all the function that will be usable after loading that library will be listed in that line. 3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are required for our library. I.e. every bash library that is in use in our bash library must be listed there. 4. The library must be listed (For more information, see ldbashconfig(8)). Basic guidelines for writing library of your own: 1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions. 2. Try to declare all variables intended for internal use as local. 3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with: __<library_name>_ For example, internal function myfoosort of hashstash library should be named as __hashstash_myfoosort This helps to avoid conflicts in global name space when using libraries that come from different vendors. 4. See html manual for full version of this guide. AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <ril@ran4.net> SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1) Linux Epoch Linux