ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

-print0 True; print the full file name on the standard output, followed by a null character (instead of the newline character that '-print' uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the '-0' option of xargs.

Now I have 2 questions:1-)May you explain how the array is loaded with this syntax? How it works?

1-)May you explain how the array is loaded with this syntax? How it works?

Code:

FILES=("${FILES[@]}" "$FILE")

The statement replaces the list in variable FILES with another list. The new list contains each and every one of the old list items, plus one new one, $FILE. For Bash, "${list[@]}" expands to each of the list elements as a separate token. Quotes are important, since Bash uses them to understand which ones are supposed to be separate tokens.

Quote:

Originally Posted by cgcamal

2-) How can be introduce the basename option?

You will need to loop thorough the FILES array, and apply basename separately to each one:

I think that only works in Bash 3 and newer. I frequently use systems with an older version of Bash, so I always try to make my scripts compatible.

Unfortunately, I cannot find reliable documentation for older versions of Bash -- even Waybackmachine is glitching right now --, so I'm not sure. If you find a good source for previous bash manuals, I'd appreciate it.