Sponsored Content
Full Discussion: How to shorten my code?
Top Forums UNIX for Dummies Questions & Answers How to shorten my code? Post 302872219 by Scrutinizer on Friday 8th of November 2013 02:52:49 AM
Old 11-08-2013
Another way to do the loop, that would not involve the cut statement:
Code:
while IFS=, read _ _ _ i _
do

done < "$PAYROLL"



--
Quote:
Originally Posted by bakunin
[..] you should not use a "for"-loop for a possibly long list, because the expansion will let the resulting line (after evaluation of the backticks) grow and shell command lines have a certain maximum length (see the "MAX_LIN" kernel constant).
The for loop is an internal compound shell command that is part of the shell syntax and it does not suffer from these limits..

Quote:
There shall be no limit on the size of any shell command other than that imposed by the underlying system (memory constraints, {ARG_MAX}, and so on).
Shell Commands

ARG_MAX is the maximum length of arguments for a new process and that is not the case here.

Even in cases where the shell calls an external program and tries to pass too many elements, then it is not the shell that imposes this limit. It only delivers the error message...
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Howto shorten script in a busybox environment by using for loops?

My satellite receiver is equipped with busybox, so a small linux version. That is why I can not use certain commands like #tomorrow in date commands or #date -d &quot;+1 day&quot; and thus I have to use: day1=$ I want to download every day 6 files from the internet but the filenames consist of the date... (6 Replies)
Discussion started by: ni_hao
6 Replies

2. Shell Programming and Scripting

script to shorten usernames and output to file

Hopefully someone here can point me in the correct direction. I'm working on a username migration and am trying to map my users ols usernames to the new ones. Right now every user has a username of firstname.lastname i.e. john.doe I'm trying to create a bash or python script that will take... (3 Replies)
Discussion started by: binary-ninja
3 Replies

3. Shell Programming and Scripting

Block of code replacement in Java source code through Unix script

Hi, I want to remove the following code from Source files (or replace the code with empty.) from all the source files in given directory. finally { if (null != hibernateSession && hibernateSession.isOpen()) { //hibernateSession.close(); } } It would be great if the script has... (2 Replies)
Discussion started by: hareeshram
2 Replies

4. UNIX for Dummies Questions & Answers

How can i use function for the below script to shorten it?

Hi All, i worte a shell script which will zcat the .gz file and write it in to a tmp file and then again cat the file and convert it to Dos mode. Next step is i am greping the file to search for the particular string on the 1st line and if the string does not exits it will insert the 1st line... (1 Reply)
Discussion started by: vikatakavi
1 Replies

5. Shell Programming and Scripting

Shorten header of protein sequences in fasta file

I have a fasta file as follows >sp|O15090|FABP4_HUMAN Fatty acid-binding protein, adipocyte OS=Homo sapiens GN=FABP4 PE=1 SV=3 MCDAFVGTWKLVSSENFDDYMKEVGVGFATRKVAGMAKPNMIISVNGDVITIKSESTFKN TEISFILGQEFDEVTADDRKVKSTITLDGGVLVHVQKWDGKSTTIKRKREDDKLVVECVM KGVTSTRVYERA >sp|L18484|AP2A2_RAT AP-2... (3 Replies)
Discussion started by: alexypaul
3 Replies

6. Shell Programming and Scripting

Ps command and awk - shorten characters

ps -e -o pcpu -o pid -o user -o args | sort -k 1 | tail -6r %CPU PID USER COMMAND 0.3 223220 root /usr/tivoli/tsm/client/ba/bin/dsmc sched 0.2 411332 root /usr/sbin/syslogd 0.1 90962 root /usr/sbin/syncd 60 0.0 10572 root -ksh 0.0 94270 root -ksh ... (4 Replies)
Discussion started by: SkySmart
4 Replies

7. Shell Programming and Scripting

Shorten header of protein sequences in fasta file to only organism name

I have a fasta file as follows >sp|Q8WWQ8|STAB2_HUMAN Stabilin-2 OS=Homo sapiens OX=9606 GN=STAB2 PE=1 SV=3 MMLQHLVIFCLGLVVQNFCSPAETTGQARRCDRKSLLTIRTECRSCALNLGVKCPDGYTM ITSGSVGVRDCRYTFEVRTYSLSLPGCRHICRKDYLQPRCCPGRWGPDCIECPGGAGSPC NGRGSCAEGMEGNGTCSCQEGFGGTACETCADDNLFGPSCSSVCNCVHGVCNSGLDGDGT... (3 Replies)
Discussion started by: jerrild
3 Replies
TPUT(1) 						    BSD General Commands Manual 						   TPUT(1)

NAME
tput, clear -- terminal capability interface SYNOPSIS
tput [-T term] attribute [attribute-args] ... DESCRIPTION
tput makes terminal-dependent information available to users or shell applications. The options are as follows: -T The terminal name as specified in the terminfo(5) database, for example, ``vt100'' or ``xterm''. If not specified, tput retrieves the ``TERM'' variable from the environment. tput outputs a string if the attribute is of type string; a number if it is of type integer. Otherwise, tput exits 0 if the terminal has the capability and 1 if it does not, without further action. If the attribute is of type string, and takes arguments (e.g. cursor movement, the terminfo ``cup'' sequence) the arguments are taken from the command line immediately following the attribute. The following special attributes are available: clear Clear the screen (the terminfo(5) ``cl'' sequence). init Initialize the terminal (the terminfo(5) ``is2'' sequence). longname Print the descriptive name of the user's terminal type. reset Reset the terminal (the terminfo(5) ``rs1, rs2, rs3'' and ``rf'' sequence). EXIT STATUS
The exit status of tput is based on the last attribute specified. If the attribute is of type string or of type integer, tput exits 0 if the attribute is defined for this terminal type and 1 if it is not. If the attribute is of type boolean, tput exits 0 if the terminal has this attribute, and 1 if it does not. tput exits 2 if any error occurred. EXAMPLES
tput cl cm 5 10 clear the screen and goto line 5 column 10 tput cm 6 11 DC 6 goto line 6 column 11 and delete 6 characters SEE ALSO
termcap(3), termcap(5) HISTORY
The tput command appears in 4.4BSD. BUGS
tput can't really distinguish between different types of attributes. Not all terminfo entries contain the reset sequence, so using the init sequence may be more useful. BSD
September 29, 2009 BSD
All times are GMT -4. The time now is 02:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy