Arrays - Raspberry Pi Forums


hi guys! new here. go doing arrays , scripting. i'm little stuck on creating script can read files of home directory array using code arrayx=( $( ls. ) )
has display empty files, directories, , files not empty. sorry new this, , stumped me. have been looking while , have not found anything. have create backup script copy directory input script location input script. if makes sense. in advance!

quite few things there, try breaking down bit.

i'm assuming bash being used of these.
create arrary of in current directory using ls

code: select all

x=( $( ls ) ) 
(hidden files not listed)
far got.

create array of empty files (0 length, real files) in current directory

code: select all

x=( $( find . -maxdepth 1 -size 0 -type f ) ) 
(filenames prefixed "./" , hidden files shown)

create array of non-empty files (not 0 length, real files) in current directory

code: select all

x=( $( find . -maxdepth 1 -size +0 -type f ) ) 
create array of directories in current directory (just top-level)

code: select all

x=( $( find . -maxdepth 1 -type d ) ) 
create array of directories in current directory , deeper, ones in same filesystem.

code: select all

x=( $( find . -xdev -type d ) ) 
backup scripts, @ rsync command. powerful doing backups, both remote , local.


raspberrypi



Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support