Question

Why is the shift command an important tool in Linux/UNIX?                                 

Why is the shift command an important tool in Linux/UNIX?                                                                                                                                                                                               13

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Yup, shift command is an important tool in Linux/UNIX not only because of it's use it for shifting purpose such as right shift or left shift or due to it's ability to perform arithmatic operations through shift command but mainly due to it's ability to provide access to various elements such as elements in array and It can also be used to loop through arguments.Shift can be applied to while,untill,and even for loops for handling arrays in much more subtle ways than can a simple for loop.

Example:

  • It lets you access the tenth argument (if there is one) more easily.  $10 doesn’t work – it’s interpreted as $1 concatenated with a 0 (and so might produce something like Hello0). After a shift, the tenth argument becomes $9. (However, in most modern shells, you can use ${10}.)
  • set -f -- $args; IFS=$split; for arg do set -- $arg; shift "${number_of_fields_to_discard}" && fn_that_wants_split_arg "$arg";
Add a comment
Know the answer?
Add Answer to:
Why is the shift command an important tool in Linux/UNIX?                                 
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT