Sponsored Content
Full Discussion: Use of Shift command
Top Forums Shell Programming and Scripting Use of Shift command Post 302570300 by ahamed101 on Thursday 3rd of November 2011 01:52:14 AM
Old 11-03-2011
Try this to get the concept...
Code:
[root@bt] $ cat run
#!/bin/bash

set -- "1" "2" "3" "4" "5"
echo $*
shift
echo $*
shift
echo $*
shift
echo $*

Output
Code:
[root@bt] $ ./run
1 2 3 4 5
2 3 4 5
3 4 5
4 5

It will shift the arguments from right to left
Lets say, you have 3 arguments i.e. $1=a, $2=b, $3=c
Now you "shift" and try priting $1, it will print "b" and $2 will be "c" and there will no $3

HTH
--ahamed
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

shift command

There is an error when i am trying to use the shift command in this way: ($1 = -d, $2 = 123, $3 = -c etc etc) for $arg in $@ do case $arg in "-d") shift; (so that the $2 will become the $arg now) (and while it loop the 2nd time,) ... (1 Reply)
Discussion started by: AkumaTay
1 Replies

2. UNIX for Dummies Questions & Answers

xterm SHIFT crazy

hi all, when I press SHIFT at once it work like as I've hold it (like CapsLock is On, but it Off) ! ... and if I press F1 (or another function key) it put out 24z :( it is occure on my remote sun 8 , xterm session help me please ! (2 Replies)
Discussion started by: oneivan
2 Replies

3. Shell Programming and Scripting

shift command

Hi Folks, In shell scripting the maximum no. of command line parameters becomes 9(Am i right). If we want to get more than 9 parameters we use the shift command. Even here there are two possibilities. 1. Without the use of variables - The arguments are lost and the lost no. is equal to the... (6 Replies)
Discussion started by: Nisha
6 Replies

4. Shell Programming and Scripting

Regarding the shift command???

I am running a program where in I have this command which is giving error the shift: number is not correct. can you please tell me how shift actually works? the line which is giving error is- set $PARAM; shift; shift; shift; shift; shift; shift; shift; shift Is it related somewhere to... (2 Replies)
Discussion started by: shrao
2 Replies

5. UNIX for Dummies Questions & Answers

shift not working

Hi, I wrote one script, in between script needs to use 10th and 11th positional parameters, that time i used "shift". Here i am facing the below find problem, ./DataCount.sh: cannot shift I tried 1) I have read man pages for shift 2) Before but * and ** 3) Simple shift with out giving... (4 Replies)
Discussion started by: Nagapandi
4 Replies

6. Shell Programming and Scripting

AIX command to shift up

I would need the awk command or a better way to get my file that looks like 1234 5678 8912 3456 7890 to look like 1234,5678,8912,3456,7890 Thanks in advance (4 Replies)
Discussion started by: bombcan
4 Replies

7. UNIX for Dummies Questions & Answers

A Shift into UNIX

Hi, Firstly, I did a search for this question both on this site and on the internet and have not been able to find a suitable answer that is not general in nature. I have always been a Windows user. I use my girl friend's mac every now and then, but I always come back to windows. For a... (1 Reply)
Discussion started by: mearex
1 Replies

8. UNIX for Dummies Questions & Answers

can someone explain shift command in script?

think using shift would help me finish my script but cant get it work without your help. would appreciate if you give me a example with shift & counter in the same script so I can later work on that to my one. Thanks and Good Luck! (1 Reply)
Discussion started by: me.
1 Replies

9. Shell Programming and Scripting

AIX function example with "shift" command

Hello, I am reading one of the AIX manuals about shell scripting and (AIX 5) and I found this example when introducing to functions: function usage { prog="$1"; shift print -u2 "$prog: usage: $prog $@" exit 1 } This example is meant to be easy but I don't understand what it is... (5 Replies)
Discussion started by: Kibou
5 Replies

10. Shell Programming and Scripting

Shift command help

#!/bin/bash hostname=$1; shift for hostname in $1 do ping $hostname done I want to run the above script as hostname.sh yahoo.com google.com cnn.com. I want to shift each hostname to $1. How can do that with above code as currently it's not shifting. (5 Replies)
Discussion started by: scj2012
5 Replies
mlib_VectorMulShift_U8_Mod(3MLIB)			    mediaLib Library Functions				 mlib_VectorMulShift_U8_Mod(3MLIB)

NAME
mlib_VectorMulShift_U8_Mod, mlib_VectorMulShift_U8_Sat, mlib_VectorMulShift_U8C_Mod, mlib_VectorMulShift_U8C_Sat, mlib_VectorMul- Shift_S8_Mod, mlib_VectorMulShift_S8_Sat, mlib_VectorMulShift_S8C_Mod, mlib_VectorMulShift_S8C_Sat, mlib_VectorMulShift_S16_Mod, mlib_Vec- torMulShift_S16_Sat, mlib_VectorMulShift_S16C_Mod, mlib_VectorMulShift_S16C_Sat, mlib_VectorMulShift_S32_Mod, mlib_VectorMulShift_S32_Sat, mlib_VectorMulShift_S32C_Mod, mlib_VectorMulShift_S32C_Sat - vector multiplication with shifting, in place SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VectorMulShift_U8_Mod(mlib_u8 *xz, const mlib_u8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_U8_Sat(mlib_u8 *xz, const mlib_u8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_U8C_Mod(mlib_u8 *xz, const mlib_u8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_U8C_Sat(mlib_u8 *xz, const mlib_u8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S8_Mod(mlib_s8 *xz, const mlib_s8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S8_Sat(mlib_s8 *xz, const mlib_s8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S8C_Mod(mlib_s8 *xz, const mlib_s8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S8C_Sat(mlib_s8 *xz, const mlib_s8 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S16_Mod(mlib_s16 *xz, const mlib_s16 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S16_Sat(mlib_s16 *xz, const mlib_s16 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S16C_Mod(mlib_s16 *xz, const mlib_s16 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S16C_Sat(mlib_s16 *xz, const mlib_s16 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S32_Mod(mlib_s32 *xz, const mlib_s32 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S32_Sat(mlib_s32 *xz, const mlib_s32 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S32C_Mod(mlib_s32 *xz, const mlib_s32 *y, mlib_s32 n, mlib_s32 shift); mlib_status mlib_VectorMulShift_S32C_Sat(mlib_s32 *xz, const mlib_s32 *y, mlib_s32 n, mlib_s32 shift); DESCRIPTION
Each of these functions performs an in-place multiplication of two vectors and shifts the result. For real data, the following equation is used: xz[i] = xz[i] * y[i] * 2**(-shift) where i = 0, 1, ..., (n - 1). For complex data, the following equation is used: tmp = xz[2*i] xz[2*i] = (tmp*y[2*i] - xz[2*i + 1]*y[2*i + 1]) * 2**(-shift) xz[2*i + 1] = (tmp*y[2*i + 1] + xz[2*i + 1]*y[2*i]) * 2**(-shift) where i = 0, 1, ..., (n - 1). PARAMETERS
Each of the functions takes the following arguments: xz Pointer to the first element of the first source and result vector. y Pointer to the first element of the second source vector. n Number of elements in each vector. shift Right shifting factor. The ranges of valid shift are: 1 <= shift <= 8 for U8, S8, U8C, S8C types 1 <= shift <= 16 for S16, S16C types 1 <= shift <= 31 for S32, S32C types RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_VectorMulShift_U8_U8_Mod(3MLIB), attributes(5) SunOS 5.10 10 Nov 2004 mlib_VectorMulShift_U8_Mod(3MLIB)
All times are GMT -4. The time now is 09:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy