Sponsored Content
Top Forums Shell Programming and Scripting Combining multiple variables into new variable Post 302525144 by dring on Wednesday 25th of May 2011 11:46:32 PM
Old 05-26-2011
hey legends,
just tested the script with an array (first time for me). check it out;
Code:
#!/bin/sh

HOME=/home/gohara/test/
ARCHIVE=archive/
DIRECTORY=( "sd1/" "sd2/" "sd3/")
FILEMASK=( "TAV*.*" "CRM*.*" "FTO*.*" )
ARCHIVETIME=( "30" "60" "90" )
DELETETIME=( "365" "90" "120" )


n=${#DIRECTORY[@]} #num elements in array DIRECTORY
for (( i=0; i<n; i++ ))

do

echo -e "\n!! Moving files older than ${ARCHIVETIME[$i]} days, like ${FILEMASK[$i]} from $HOME${DIRECTORY[$i]} to $HOME${DIRECTORY[$i]}$ARCHIVE...\n"

find $HOME${DIRECTORY[$i]}${FILEMASK[$i]} -type f -mtime +${ARCHIVETIME[$i]} -exec ls {} \;

find $HOME${DIRECTORY[$i]}${FILEMASK[$i]} -type f -mtime +${ARCHIVETIME[$i]} -exec mv {} $HOME${DIRECTORY[$i]}$ARCHIVE  \;

echo -e "\n!! Deleting files older than ${DELETETIME[$i]} days from $HOME${DIRECTORY[$i]}$ARCHIVE\n"

find $HOME${DIRECTORY[$i]}$ARCHIVE${FILEMASK[$i]} -type f -mtime +${DELETETIME[$i]} -exec ls {} \;

find $HOME${DIRECTORY[$i]}$ARCHIVE${FILEMASK[$i]} -type f -mtime +${DELETETIME[$i]} -exec rm {} \;

echo -e "\n!! Archive complete for ${DIRECTORY[$i]}\n\n"

done

echo -e "\n\n!! Script Complete\n"

---------- Post updated at 01:46 PM ---------- Previous update was at 01:45 PM ----------

now i just gotta try retriving the variables from a config file, and outputting all the info to a log file!!

Last edited by Scott; 05-26-2011 at 01:36 AM.. Reason: Code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining multiple lines

I am fairly new to scripting. But I have been able to extract and format all of my information required into one file. My issue is that one character is on a separate line. I need to be able to add the character to the previous line. ex. abcdefghi 1 bcdefghij 3 cdefghijk 4 need to... (4 Replies)
Discussion started by: DUST
4 Replies

2. Shell Programming and Scripting

Combining multiple commands

Hi Guys, I am looking to optimze these 5 SSH lines to a single SSH to get my machine to not hang! lol! cat hosts.lst | xargs -n1 -t -i echo 'home/util/timeout 6 0 ssh -q {} top -b > util/{}.top &' >> r_query_info cat hosts.lst | xargs -n1 -t -i echo 'home/util/timeout 6 0 ssh -q {} uname -r... (5 Replies)
Discussion started by: wick3dsunny
5 Replies

3. Shell Programming and Scripting

Combining two variables in ksh

I can't believe I can't figure this out... given this code: CARS_DATA_LIST=`cat /tmp/file1 | awk '{print $1}' ` FMSA_DATA_LIST=`cat /tmp/file2 | awk '{print $1}' ` The value of each of the above variables is: CARS = a b c d e f g FMSA = a b c q r s I want to declare a third... (8 Replies)
Discussion started by: Shoeless_Mike
8 Replies

4. Shell Programming and Scripting

Problem combining two variables into one

Hello, I have a problem combining two variables into one. I did the following: in my env variables i had set PATH_DESTINATION_1=/root/path_one PATH_DESTINATION_2=/root/path_two #!/usr/bin/ksh count=1 count_path=2 while do (3 Replies)
Discussion started by: Eraser
3 Replies

5. Shell Programming and Scripting

Combining multiple files into one with the same name/different extension

I've been trying to find information in regard to creating a script that will generate HTML files. I currently have a series of files that contain code I need to surround with a <textarea> tag for easy viewing. I have about a thousand files that contain code, one file that contains the HTML code up... (10 Replies)
Discussion started by: 12o
10 Replies

6. Shell Programming and Scripting

Combining multiple files

I have 2 files. each having 3 coloums 1st field date as 20130322 2nd field time as 05:55 3rd field numberic value File 2 has entries missing for some date time. FILE1 20130322 05:35 2219 20130322 05:40 1809 20130322 05:45 1617 20130322 05:50 ... (2 Replies)
Discussion started by: sandeepkmehra
2 Replies

7. UNIX for Beginners Questions & Answers

Combining multiple files into one

Hello Everyone, I have 4 different files (one column in each) that I'm trying to combine into 1 file with four columns. Having issues trying to get the columns to format properly. I have tried the following: paste file1 file2 file3 file4 | column -s $'\t' -t > results.txt paste file1 file2... (1 Reply)
Discussion started by: malk71
1 Replies

8. Shell Programming and Scripting

Combining a declared variable with a temporary variable

Hi folks! Kind of a noob question... from an OLD AIX/HPUX Admin. I am writing a script to ease use of a command; an extended aliasing if you will. What I want to do is set several variables (OPT1, OPT2, etc) with command arguments, such as --help, --list-all, etc. Later in the script, I... (5 Replies)
Discussion started by: clee
5 Replies

9. UNIX for Beginners Questions & Answers

Combining multiple greps

I'm trying to learn about regular expressions. Let's say I want to list all the files in /usr/bin beginning with "p", ending with "x", and containing an "a". I know this works:ls | grep ^p | grep x$ | grep abut I'm thinking there must be a way to do it without typing grep three times. Some of my... (9 Replies)
Discussion started by: Xubuntu56
9 Replies

10. UNIX for Beginners Questions & Answers

Help using combining variables with sed command (RHEL 7)

Here is the whole script, very simple, but I am just learning ROK_NO=$1 RPT=/tmp/test sed -E '/^SELECT/ s/(.{23}).{8}/\1'"$ROK_NO"' /' $RPT echo $RPT When I run this I get $ bash rok.sh 2388085 : No such file or directory /tmp/test When I type the command in console, it works... (3 Replies)
Discussion started by: isey78
3 Replies
GFXBOOT(8)						       System configuration							GFXBOOT(8)

NAME
gfxboot - graphical boot screen test and config tool SYNOPSIS
gfxboot [ OPTIONS ] ARGS DESCRIPTION
gfxboot modifies and tests graphical boot loader configuration. OPTIONS
General options -a, --archive FILE|DIRECTORY Use FILE as gfxboot archive (default is /boot/message). If it points to a directory, assume it is an expanded archive (see --expand-archive option below). -v, --verbose Increase verbosity. --save-temp Keep temporary files. --version Show gfxboot version. --help Print usage. Switching themes --new-theme THEME Activate THEME. Theme files are stored in /etc/bootsplash/themes/THEME/bootloader. --update-theme THEME Activate THEME but keep language settings from current gfxboot archive. Changing gfxboot config --show-config Show gfxboot config file (gfxboot.cfg). --change-config [SECTION1::]OPTION1=FOO1 [SECTION2::]OPTION2=FOO2 ... Change gfxboot config options. If sections are omitted, section "base" is used. --rm-config [SECTION1::]OPTION1 [SECTION2::]OPTION2 ... Delete gfxboot config options. If sections are omitted, section "base" is used. --rm-section SECTION1 SECTION2 ... Delete sections in gfxboot config file. --default-language LANG Make LANG the default language. LANG is a locale string (e.g. en_US). --add-languages LANG1 LANG2 ... Add translation files. --rm-languages LANG1 LANG2 ... Remove translation files. --config-file FILE Don't work on gfxboot.cfg from gfxboot archive but on FILE. NOTE: FILE will be modified even with "--test". Preview/test gfxboot setup -p, --preview Try current config (needs some virtual machine). -t, --test Test only (don't actually change any files). -b, --bootloader BOOTLOADER Use BOOTLOADER (grub, lilo, isolinux, syslinux, pxelinux) for preview. -m, --vm VM Use virtual machine VM (bochs, qemu, qemu32, qemu64, vbox, vbox64, vmplayer, vmware) for preview. --grub DIRECTORY|RPM Use grub from DIRECTORY or RPM (default is /). --lilo DIRECTORY|RPM Use lilo from DIRECTORY or RPM (default is /). --syslinux DIRECTORY|RPM Use syslinux from DIRECTORY or RPM (default is /). --isolinux DIRECTORY|RPM Use isolinux from DIRECTORY or RPM (default is /). --pxelinux DIRECTORY|RPM Use pxelinux from DIRECTORY or RPM (default is /). --password PASSWORD Create test config with PASSWORD for preview. --32 Create 32 bit test image. --64 Create 64 bit test image. --biarch Create biarch test image (same as using --32 and --64). --cdrom, --dvd Create iso image for preview. --disk Create harddisk image for preview. --floppy Create floppy image for preview. --net Create tftp directory for preview. --save-image FILE Copy preview image to FILE. --test-add-files FILE1 FILE2 ... Add files to test directory. --test-rm-files FILE1 FILE2 ... Delete files from test directory. Adding/removing files from gfxboot archive --ls, --list-files List gfxboot archive files. --add-files FILE1 FILE2 ... Add files to gfxboot archive. --rm-files FILE1 FILE2 ... Delete files from gfxboot archive. --extract-files FILE1 FILE2 ... Copy files from gfxboot archive to current working directory. --show-file FILE Print FILE. --expand-archive DIRECTORY Create expanded gfxboot archive version in DIRECTORY. That is, only files that cannot be read directly from file system are kept in a cpio archive. All others are unpacked. Use only for isolinux, syslinux, or pxelinux. --pack-archive FILE Pack all gfxboot files into cpio archive FILE. Modifying help files --help-show FILE Print FILE (internal help file format) as HTML. --help-create FILE Convert HTML files passed as ARGS to FILE (internal format). --used-pages LINK1 LINK2 ... Mark pages as referenced. --navi FILE Use FILE as template for navigation links. --define ENTITY1=VALUE1 ENTITY2=VALUE2 ... Define ENTITYx with VALUEx. FILES
/boot/message bootloader graphics archive (actually a cpio achive) /etc/bootsplash/themes theme directory /etc/sysconfig/bootsplash default theme BUGS
None. AUTHOR
Written by Steffen Winterfeldt. SEE ALSO
If you want to create your own theme look at the gfxboot-devel package. gfxboot July 2008 GFXBOOT(8)
All times are GMT -4. The time now is 05:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy