Sponsored Content
Top Forums Shell Programming and Scripting Getting current folder name appended to all desired files Post 302514623 by ahamed101 on Sunday 17th of April 2011 05:06:55 AM
Old 04-17-2011
I am not sure why it creates the merged file in the main folder.
Anyways you can try this giving the full folder path

Code:
    ...
    grep '.*' *.txt > $HOMEDIR/$dir/_merged_temp.txt
    sed -i 's/.txt:/ /g' $HOMEDIR/$dir/_merged_temp.txt
    ...

regards,
Ahamed
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Pack current folder

How do I pack (using tar zcvf ?) the current folder inluding all files and folders ?? I need to be sure to get all files and folders/subfolders... Later I will unpack into a new folder on a new server.. Appreciate any help.. (3 Replies)
Discussion started by: WebWatch
3 Replies

2. Shell Programming and Scripting

Use awk to create new folder in current directory

Alright, I am sure this is a laughable question, but I don't know so I am going to ask anyway. I have a little script I am writing to take information from one source, recode it in a certain way, and print to files for each subject I have data for. This all works perfectly. I just want to put... (6 Replies)
Discussion started by: ccox85
6 Replies

3. UNIX for Dummies Questions & Answers

How to copy set of files with date appended to their name

Hi gurus, I have set of files in a directory ex : test_file1.csv test_file2.csv test_file3.csv my requirement is to copy these files into another directory but with date appended to the name : like after copying the files should look like : test_file1_07072008.csv ... (7 Replies)
Discussion started by: sish78
7 Replies

4. Shell Programming and Scripting

How to find files in current folder only?

How do I find files in current folder only? We are on AIX 5.3, so maxdepth is not supported. I tried to do this find /dir1/dir2/dir3/dir4 -prune -type f to display all files in /dir1/dir2/dir3/dir4 only but it does not show any files. Somehow the -prune option works for dir3 level... (7 Replies)
Discussion started by: Hangman2
7 Replies

5. UNIX for Dummies Questions & Answers

tar file from current folder

Hello guys, I am sure this has been asked before, but honestly, I cant find post talking about it. Here is what I need: - A tar file will be generated manually by user - This tar file is then used within a bash shell script My source folder structure is like this: ... (2 Replies)
Discussion started by: manolain
2 Replies

6. Shell Programming and Scripting

Convert all files in current folder from UTF8 to ANSI, name unchanged.

Asking for a Linux command line to convert all files in current folder from UTF8 to ANSI, name unchanged. Best Regards Pei (3 Replies)
Discussion started by: jiapei100
3 Replies

7. Shell Programming and Scripting

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (1 Reply)
Discussion started by: johannd
1 Replies

8. UNIX for Dummies Questions & Answers

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (7 Replies)
Discussion started by: johannd
7 Replies

9. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

10. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies
SCANDIR(3)								 1								SCANDIR(3)

scandir - List files and directories inside the specified path

SYNOPSIS
array scandir (string $directory, [int $sorting_order = SCANDIR_SORT_ASCENDING], [resource $context]) DESCRIPTION
Returns an array of files and directories from the $directory. PARAMETERS
o $directory - The directory that will be scanned. o $sorting_order - By default, the sorted order is alphabetical in ascending order. If the optional $sorting_order is set to SCANDIR_SORT_DESCEND- ING, then the sort order is alphabetical in descending order. If it is set to SCANDIR_SORT_NONE then the result is unsorted. o $context - For a description of the $context parameter, refer to the streams section of the manual. RETURN VALUES
Returns an array of filenames on success, or FALSE on failure. If $directory is not a directory, then boolean FALSE is returned, and an error of level E_WARNING is generated. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.4.0 | | | | | | | $sorting_orderconstants were added. Any nonzero | | | value caused descending order in previous ver- | | | sions. So for all PHP versions, use 0 for ascend- | | | ing order, and 1 for descending order. An option | | | for SCANDIR_SORT_NONE behavior did not exist | | | prior to PHP 5.4.0. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 A simple scandir(3) example <?php $dir = '/tmp'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2); ?> The above example will output something similar to: Array ( [0] => . [1] => .. [2] => bar.php [3] => foo.txt [4] => somedir ) Array ( [0] => somedir [1] => foo.txt [2] => bar.php [3] => .. [4] => . ) Example #2 PHP 4 alternatives to scandir(3) <?php $dir = "/tmp"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } sort($files); print_r($files); rsort($files); print_r($files); ?> The above example will output something similar to: Array ( [0] => . [1] => .. [2] => bar.php [3] => foo.txt [4] => somedir ) Array ( [0] => somedir [1] => foo.txt [2] => bar.php [3] => .. [4] => . ) NOTES
Tip A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen(3) for more details on how to specify the filename. See the "Supported Protocols and Wrappers" for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide. SEE ALSO
opendir(3), readdir(3), glob(3), is_dir(3), sort(3). PHP Documentation Group SCANDIR(3)
All times are GMT -4. The time now is 12:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy