Sponsored Content
Top Forums Shell Programming and Scripting Recurse directories and return random file Post 303020483 by triplemaya on Friday 20th of July 2018 02:58:40 PM
Old 07-20-2018
[SOLVED] Recurse directories and return random file

I have a nice program to change the background but I want it to operate on subdirectories as well.

Code:
# Script to randomly set Background from files in a directory
while true;do

# Directory Containing Pictures
DIR="/home/pc/Pictures"

# Internal Field Separator set to newline, so file names with
# spaces do not break our script.
IFS='
'

# Command to Select a random jpg file from directory
PIC=$(ls $DIR/*.jpg | shuf -n1)

# Command to set Background Image
gsettings set org.mate.background picture-filename $PIC

# specify how long to wait in seconds between changes
sleep 600

done


Last edited by triplemaya; 07-21-2018 at 09:22 AM.. Reason: SOLVED
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

scp transmits ok but random return code

Appreciate your thoughts....I m very new to this. Anyone here have the similar experience and work around. Thanks. Use scp to send a file from HP-UX to SUN box successfully but return code randomly being generated. The majority of time reports 1 (meaning not ok) and sometime 0 (OK). When scp... (0 Replies)
Discussion started by: huiraym
0 Replies

2. UNIX for Dummies Questions & Answers

recurse through filesystem to delete files

howdy all -- I recently trashed my old PC and bought a MacBook. Moving all my files over, I find I've got a zillion instances of stupid Windows files like Thumbs.db and desktop.ini all over the place. I'm looking for a way to delete them all at once (deleting each manually would take forever),... (2 Replies)
Discussion started by: mdtreky
2 Replies

3. UNIX for Dummies Questions & Answers

Any way to grep a string in directories and return the result with diskusage aswell?

What Im basically trying to do is this: I have a small script that can grep any parameter entered into a search string, then print to the screen the name of each file the parameter appears in as well as the file path, ie the directory. The code Im using just for this is.... Directory... (3 Replies)
Discussion started by: Eddeh
3 Replies

4. Shell Programming and Scripting

how to change the current file processing to some other random file in awk ?

Hello, say suppose i am processing an file emp.dat the field of which are deptno empno empname etc now say suppose i want to change the file to emp.lst then how can i do it? Here i what i attempted but in vain BEGIN{ system("sort emp.dat > emp.lst") FILENAME="emp.lst" } { print... (2 Replies)
Discussion started by: salman4u
2 Replies

5. UNIX for Dummies Questions & Answers

Copy file into directories and sub-directories

Hello- I need to copy a file into multiple directories, and each directory's sub-directories (of which there are 5) Currently, the parent directory is set up like this: dir1 sub-dir1 sub-dir2 sub-dir3 sub-dir4 sub-dir5 dir2 sub-dir1 sub-dir2 sub-dir3 ... (1 Reply)
Discussion started by: penlok
1 Replies

6. Shell Programming and Scripting

Return all sub directories on ftp server

Hey guys, I'm new to the programming world in general, and I only write in applescript so far. I am trying to find a shell script that will return a list of all the sub directories (or folders) within a directory on my ftp server. The server needs a username and password. I would assume the... (4 Replies)
Discussion started by: thriftinkid
4 Replies

7. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

8. Shell Programming and Scripting

Function - play # uses mplayer random directories

I have this in my .bashrc and use it to play my music. It is organized by directories and this will play them in random order: play(){ ## play directories with mplayer (random) if then # if no option show music types echo -n " play {directory|style} Styles: -------" find... (0 Replies)
Discussion started by: bdragon
0 Replies

9. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

10. Shell Programming and Scripting

Clear contents of specified directories, then return exit status

Hello, this is my first post here. I'm attempting to write a bash shell script to rm the contents of a directory without deleting the directory, specifically in OS X 10.10 . Here's what I have: function clear() { USER="$USER" DIR=$1 rm -rfv /Users/"$USER"/library/$DIR/* } clear... (6 Replies)
Discussion started by: YouNicks
6 Replies
PIC2GRAPH(1)						      General Commands Manual						      PIC2GRAPH(1)

NAME
pic2graph - convert a PIC diagram into a cropped image SYNOPSIS
pic2graph [ -unsafe ] [ -format fmt ] [ -eqn delim ] DESCRIPTION
Reads a PIC program as input; produces an image file (by default in Portable Network Graphics format) suitable for the Web as output. Also translates eqn(1) constructs, so it can be used for generating images of mathematical formulae. PIC is a rather expressive graphics minilanguage suitable for producing box-and-arrow diagrams of the kind frequently used in technical papers and textbooks. The language is sufficiently flexible to be quite useful for state charts, Petri-net diagrams, flow charts, simple circuit schematics, jumper layouts, and other kinds of illustration involving repetitive uses of simple geometric forms and splines. Because PIC descriptions are procedural and object-based, they are both compact and easy to modify. The PIC language is fully documented in "Making Pictures With GNU PIC", a document which is part of the groff(1) distribution. Your input PIC code should not be wrapped with the .PS and .PE macros that normally guard it within groff(1) macros. The output image will be a black-on-white graphic clipped to the smallest possible bounding box that contains all the black pixels. By specifying command-line options to be passed to convert(1) you can give it a border, set the background transparent, set the image's pixel density, or perform other useful transformations. This program uses pic(1), eqn(1), groff(1), gs(1), and the ImageMagick convert(1) program. These programs must be installed on your system and accessible on your $PATH for pic2graph to work. OPTIONS
-unsafe Run pic(1) and groff(1) in the `unsafe' mode enabling the PIC macro sh to execute arbitrary commands. The default is to forbid this. -format fmt Specify an output format; the default is PNG (Portable Network Graphics). Any format that convert(1) can emit is supported. -eqn delim Change the fencepost characters that delimit eqn(1) directives ($ and $, by default). This option requires an argument, but an empty string is accepted as a directive to disable eqn(1) processing. Command-line switches and arguments not listed above are passed to convert(1). FILES
/usr/share/groff/1.18.1/tmac/eqnrc The eqn(1) initialization file. SEE ALSO
eqn2graph(1), pic(1), eqn(1), groff(1), gs(1), convert(1). AUTHOR
Eric S. Raymond <esr@thyrsus.com>, based on a recipe by W. Richard Stevens. Groff Version 1.18.1 17 July 2002 PIC2GRAPH(1)
All times are GMT -4. The time now is 10:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy