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

Post #302575322 by vbe on Monday 21st of November 2011 10:11:14 AM

You will have to explain to me what you are trying to do in your script (I don't get you here... especially $1 $2 ...).

What are you trying to achieve? An almost exact copy of a directory content to a new directory? If so why not use appropriate unix commands ( but I can understand you also want to perfect your understanding and improve in shell scripting ! SmilieSmilie
Test Your Knowledge in Computers #864
Difficulty: Medium
In 2019, the UNIX.com UserCP was rewritten in Vue.js by Neo.
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
rmdir(1)						      General Commands Manual							  rmdir(1)

rmdir - Removes a directory SYNOPSIS
rmdir [-p] [-s] directory... STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: rmdir: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Removes all directories in a path name. For each directory argument, the directory entry it names is removed. If the directory argument includes more than one path name component, effects equivalent to the following command occur: rmdir -p $(dirname directory) That is, rmdir recursively removes each directory in the path name. OPERANDS
The path name of an empty directory to be removed. DESCRIPTION
The rmdir command removes a directory from the system. The directory must be empty before you can remove it, and you must have write per- mission in its parent directory. Use the ls -al command to see if a directory is empty. If a directory and a subdirectory of that directory are specified in a single invocation of rmdir, the subdirectory must be specified before the parent directory so that the parent directory will be empty when rmdir tries to remove it. RESTRICTIONS
A directory must be empty before you can remove it, and you must have write permission in its parent directory. If the -p option is used, all directories in the path must be empty except for the directory being recursively removed. EXIT STATUS
The following exit values are returned: Each directory specified by directory operand was successfully removed. An error occurred. EXAMPLES
To empty and remove a directory, enter: rm mydir/* mydir/.* rmdir mydir This removes the contents of mydir, then removes the empty directory. The rm command displays an error message about trying to remove the directories . (dot) and .. (dot dot), and then rmdir removes them. Note that rm mydir/* mydir/.* first removes files with names that do not begin with a (dot), then those with names that do begin with a (dot). You may not realize that the directory contains file names that begin with a (dot) because the ls command does not normally list them unless you use the -a option to see the files whose names begin with a (dot). To remove all of the directories in the path name a/b/c, enter: rmdir -p a/b/c Use a command like this one if directory a in the current directory is empty except that it contains a directory b and a/b is empty except that it contains a directory c. ENVIRONMENT VARIABLES
The following environment variables affect the execution of rmdir: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: mkdir(1), ls(1), rm(1) Functions: rmdir(2), unlink(2), remove(3) Standards: standards(5) rmdir(1)

Featured Tech Videos

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