Sponsored Content
Full Discussion: loop alternative?
Top Forums Shell Programming and Scripting loop alternative? Post 20630 by Perderabo on Tuesday 30th of April 2002 03:38:41 PM
Old 04-30-2002
Try this:

Code:
#! /usr/bin/ksh
exec < inputfile > outputfile
while read n ; do
       ((n=n-1))
       print $n
done
exit 0

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Alternative for a while read line loop

HELLO all :), I have been trying to use a simple while loop to read a file " templist", line by line and perform an action. See the code below. The reason for not using a while read line loop is the for the use of the if condition that wouldn't work. I would appreciate some ideas as this has... (2 Replies)
Discussion started by: kabs
2 Replies

2. Shell Programming and Scripting

getopts alternative?

I have to implement switches (options) like this in my script. ./myscript -help ./myscript -dir /home/krish -all ./myscript -all getopts allows switches to have one character (like a, b, etc.). How can I customize it for handling the above situation? Or, is there any alternative to... (3 Replies)
Discussion started by: krishmaths
3 Replies

3. Shell Programming and Scripting

help with while loop or any other alternative?

i=1 while do mm=02 dd=03 yy=2008 echo "$mm$dd$yy" i=$(( i+1)) echo "$i" done whenever i execute the script above i will get the error below: syntax error at line 30: `i=$' unexpected (3 Replies)
Discussion started by: filthymonk
3 Replies

4. Shell Programming and Scripting

Alternative for Cron

Hi... I want to know whether if there is any alternative for cron.:confused: I had written a script which checks for all system/application processes every 15 min(placed in cron though). But looks funny - what if cron daemon isn't running!! and expecting that script to update the OUTPUT FILE... (5 Replies)
Discussion started by: reddybs
5 Replies

5. Shell Programming and Scripting

Alternative for wc -l

Hi techies .. This is my first posting hr .. Am facing a serious performance problem in counting the number of lines in the file. The input files i get will be in some 10 to 15 Gb of size or even sometimes more ..and I will load it to db I have used wc -l to confirm whether the loader... (14 Replies)
Discussion started by: rajesh_2383
14 Replies

6. Solaris

vi alternative

Is there any other editor, installed by 'default' in Sparc Solaris10, besides vi? I'd like to avoid installing anything new. If not, how to make vi more user-friendly? thanks. (8 Replies)
Discussion started by: orange47
8 Replies

7. Shell Programming and Scripting

Alternative to the loop is needed

I have a file containing ids like this (file1): c9e2c3c6c100000000460000c02000803c63e529c3f5f5f0 c9e2c3c6c100000000460000c02002813c63e539c3f5f5f0 c9e2c3c6c100000000460000c02002ee3c63ebb1c3f5f5f4 c9e2c3c6c100000000460000c020042f3c63e549c3f5f5f0 These ids are present in muiltiple files named:... (4 Replies)
Discussion started by: niladri29
4 Replies

8. Shell Programming and Scripting

Looking for an alternative to Tcl

I've created quite a collection of tcl scripts which have buttons, radio buttons, check boxes, text fields, etc. These tcl scripts in turn call and execute several hundred sh, csh, bash, perl scripts and pass in the args based on the gui selections on the same and other redhat machines. We're... (4 Replies)
Discussion started by: scottwevans
4 Replies

9. Shell Programming and Scripting

Alternative to Sleep?

Greetings. I've been wondering about this one for some time: Is there an alternative to sleep in bash? The reason: I'd like to simply limit the amount of processor usage in continuous while : script scenarios without spawning endless sleep processes as well. After beating the manpages, I... (14 Replies)
Discussion started by: LinQ
14 Replies

10. Shell Programming and Scripting

Please help -- any alternative to expect ?

Doing some automation to automate some server tasks in Linux through shell scripting. In the script I tried to call a expect script to log into another server and execute a command. Please note: passwordless SSH is not possible hence am trying some User-interactive commands like Expect to send... (2 Replies)
Discussion started by: alldbest
2 Replies
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/ksh93 /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/ksh93 /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/sfw/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. NOTES
Restricted shells should not be listed in /etc/shells. SunOS 5.11 1 Nov 2007 getusershell(3C)
All times are GMT -4. The time now is 01:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy