"[Solved] take name of directory and files as variables"

Post #302575292 by me. on Monday 21st of November 2011 08:28:52 AM

[Solved] take name of directory and files as variables


want to create script that takes name of directory and all files and will copy each file to new directory.
then fix errors like files do not exist or no permission to create new directory...

these what I have so far...


for i in $(pwd) $(ls)
echo "$i"
if [ -d $dir ]; then
cp -a * ~/Documents/Scripts/Copy #these would copy all files to Copy dir
                                           #but I want copy them one by one with
                                           #message that each one was copied
echo " files copied to directory $dir "
mkdir Copy && cp $i $dir
echo " $2 copied to directory $dir "

Last edited by vbe; 11-21-2011 at 12:33 PM..
Test Your Knowledge in Computers #525
Difficulty: Medium
In ASCII, to convert between uppercase and lowercase versions, you only need to invert the second bit (0 for uppercase, 1 for lowercase).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

2. UNIX for Dummies Questions & Answers

[SOLVED] Delete files and folders under given directory

I have a requirement to delete the files and folders under a given directory. my directory structure is like this.. Data | A(Directory) |_PDF(Directory)----pdf files |_XML()Directory --xml files |--files | B(Directory) |_PDF(Directory)----pdf files |_XML()Directory --xml files ... (1 Reply)
Discussion started by: ramse8pc
1 Replies

3. Shell Programming and Scripting

[Solved] Look for strings and use variables

Hello guys, First of all, thanks for taking the time to read my post. So, here I have a file from my honeypot which record IP addresses and web pages visited. I would like to manipulate it in order to create Snort signatures and ACLs. But I am having troubles to extract the src IP address and... (6 Replies)
Discussion started by: Benou
6 Replies

4. Shell Programming and Scripting

[Solved] Bash test 2 variables to see if ones greater by n

Experts, I have a bash shell script that generates 2 variables that have the current minute and a minute from a log file. Can someone please show me the best way to test if the minutes stray by 5. So basically if: This is ok: Last Fitting Min ============= 02 Current Minute =============... (2 Replies)
Discussion started by: jaysunn
2 Replies

5. Shell Programming and Scripting

Moving files from one directory to another based on 2 date variables

Hi All, I am currently coding for a requirement(LINUX OS) where I am supposed to move a file (Lets Call it Employee.txt) from Directory A to Directory B based on 2 date fields as below, Date_Current = 20120620 Date_Previous = 20120610 Source Directory : /iis_data/source Target... (11 Replies)
Discussion started by: dsfreddie
11 Replies

6. Shell Programming and Scripting

[Solved] Working with date (add minutes using variables)

Dear all, today I'm scratching my head with a simple (I believe) issue. Working with date is quite simple, so if I Need to add some seconds to current time, I'll use: date --date='+30 seconds' +"%Y-%m-%d %H:%M:%S"But, how to pass the value to add from a variable? I tried the following without... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

7. Shell Programming and Scripting

[solved] Question for using variables outside a while loop

I want to get newvar outside the while any ideas? while read myline; do var=${myline} newvar1=$(let "$var") done echo $newvar1 I found it its ok now Thank you! (0 Replies)
Discussion started by: sanantonio7777
0 Replies

8. UNIX for Dummies Questions & Answers

[Solved] Writing a loop to changing the names of files in a directory

Hi, I would like to write a loop to change the names of files in a directory. The files are called data1.txt through data1000.txt. I'd like to change their names to a1.txt through a1000.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

9. Shell Programming and Scripting

[SOLVED] nawk FS using pipe read variables from file

I have a file data_1.out which contains: 1|abc mail|mail subject|mail body 2|def mail|mail subject|def mail body I am trying to read the variables from data_1.out and use them to print to 2 different files based on the id (first_column) The problem is I am not able to read the file... (8 Replies)
Discussion started by: sol_nov
8 Replies

10. UNIX for Dummies Questions & Answers

[Solved] How to find particular files ina directory?

Hi, I am trying to write a script to find some files in a directory Example: if i have files like 2014-02-01_aaaa.txt 2014-02-01_bbbb.txt 2014-02-01_cccc.txt 2014-02-01_dddd.txt and some other files how can i just check to see if there four files exits or not i tried some thing like this... (5 Replies)
Discussion started by: vikatakavi
5 Replies
environ(4)							   File Formats 							environ(4)

environ, pref, variables - user-preference variables files for AT&T FACE SYNOPSIS
$HOME/pref/.environ $HOME/pref/.variables $HOME/FILECABINET/.pref $HOME/WASTEBASKET/.pref DESCRIPTION
The .environ, .pref, and .variables files contain variables that indicate user preferences for a variety of operations. The .environ and .variables files are located under the user's $HOME/pref directory. The .pref files are found under $HOME/FILECABINET, $HOME/WASTEBASKET, and any directory where preferences were set via the organize command. Names and descriptions for each variable are presented below. Vari- ables are listed one per line and are of the form variable=value. .environ Variables Variables found in .environ include: LOGINWIN[1-4] Windows that are opened when FACE is initialized. SORTMODE Sort mode for file folder listings. Values include the following hexadecimal digits: 1 Sorted alphabetically by name. 2 Files most recently modified first. 800 Sorted alphabetically by object type. The values above may be listed in reverse order by ORing the following value: 1000 List objects in reverse order. For example, a value of 1002 will produce a folder listing with files LEAST recently modified displayed first. A value of 1001 would produce a "reverse" alphabetical by name listing of the folder. DISPLAYMODE Display mode for file folders. Values include the following hexadecimal digits: 0 File names only. 4 File names and brief description. 8 File names, description, plus additional information. WASTEPROMPT Prompt before emptying wastebasket (yes/no?). WASTEDAYS Number of days before emptying wastebasket. PRINCMD[1-3] Print command defined to print files. UMASK Holds default permissions with which files will be created. .pref Variables Variables found in .pref are the following: SORTMODE Contains the same values as the SORTMODE variable described in .environ above. DISPMODE Contains the same values as the DISPLAYMODE variable described in .environ above. .variable Variables Variables found in .variables include: EDITOR Default editor. PS1 Shell prompt. SunOS 5.10 3 Jul 1990 environ(4)

Featured Tech Videos

All times are GMT -4. The time now is 03:23 PM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy