Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Move same files and issue ls -al command on remaining files Post 302503954 by methyl on Saturday 12th of March 2011 06:11:55 PM
Old 03-12-2011
The problem is that "ls -a" includes the directories "." and ".." .
Hint: "ls -A" does not include "." and ".." .


If you want a directory list of only the files in the directory and don't want anything from subdirectories it gets a little more complicated. This example script is will allow for filenames containing space characters and also avoids descending directory trees. The method assumes that you don't have a version of the find command which has the "-maxdepth" parameter. I've also avoided an open-ended "for" command which is prone to failure in some Operating System versions (e.g. some AIX).
Redirecting STDERR (channel 2) allows for there to be no match.

Code:
ls -Ad "$1"/* 2>/dev/null | while read file
do
    if [ -f "${file}" ]
    then
          ls -lad "${file}"
    fi
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Move client files using UNIX command.

Is there a way to move file on the client(PC) from the UNIX command? i.e. copy c:\file1 to d:\file1. I like to use it in my unix script. I could copy file between the client and unix server using the following: print "\033&oBreceive $DESTFILE from $SOURCEFILE ascii delete" I was wonderful if... (2 Replies)
Discussion started by: pputh
2 Replies

2. UNIX for Dummies Questions & Answers

UNIX command: mv - Objective: move files based on timestamp

I was wondering if there was a command to move files from one directory to another subdirectory based on the timestamp, i.e. moving from directory A files that have a timestamp of before the year 2005 into directory B. Directory B is a subdirectory located in directory A. I was advised to... (4 Replies)
Discussion started by: HLee1981
4 Replies

3. Shell Programming and Scripting

Insert first line of a file to first column of remaining files

I want to extraxt data from a html table the html file is downloaded from UG / PG Univ - Exam.Results April/May 2008 After processing the html file using sed i got the output like this 11305106082,RANJANI R, CS1251,20,69,P CS1302,20,45,P EC1006,20,52,P EC1351,20,53,P... (5 Replies)
Discussion started by: a_artha
5 Replies

4. Shell Programming and Scripting

Help with command to Move files by X number to seperate directories

Hello, I need help finding a script that will allow me to move files from one directory to another directory 10k files at a time. I have a directory that has 100 K files in it. I need to have those 100k files broken apart to separate directories each with 10k files in them. Here is the... (8 Replies)
Discussion started by: Geo_Bean
8 Replies

5. Shell Programming and Scripting

Recursively move directories along with files/specific files

I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find ) The directory structure looks like :- /tmp a.log b.log c.log /abcd d.log e.log When I tried the following command , it movies all the log files... (8 Replies)
Discussion started by: frintocf
8 Replies

6. Shell Programming and Scripting

Move all files except sys date (today) files in Solaris 10

I want to move all files from one directory to another directory excluding today (sysdate files) on daily basis. file name is in pattern file_2013031801, file_2013031802 etc (2 Replies)
Discussion started by: khattak
2 Replies

7. Shell Programming and Scripting

find command to move the files to other folder - ksh 88

Hi , I've learnt that the following command will remove the files from the given folder for given no.of days find /home/etc -type f -atime -10 -exec rm -f {} \; But how can I change the above command that will move the files to another specified directory instead of removing the... (1 Reply)
Discussion started by: smile689
1 Replies

8. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

9. Shell Programming and Scripting

Move multiple files to different directory using a single command

I have multiple files test1, test2, test3 etc. I want to move to a different directory with ABC_ prefixed to every file and and current dat time as postfix using a single command. (I will be using this is sftp with ! (command for local server). I have tried the following but it gives error ... (5 Replies)
Discussion started by: Soham
5 Replies

10. Shell Programming and Scripting

Move files with a certain suffix based on how many files are in another folder

Hello, First time poster. I am looking for a way to script or program the process of moving files from one folder to another, automatically, based on the count of files in the destination folder. I was thinking a shell script would work, but am open to the suggestions of the experts... (6 Replies)
Discussion started by: comtech
6 Replies
ha(1)								    HA archiver 							     ha(1)

NAME
ha - a small file archiver utility SYNOPSIS
ha <command>[<option><option>...] archive [ name ... ] DESCRIPTION
After the program name comes a command name (single letter) and options (single letters, appended to the command name without a space). COMMANDS
a[sdqemr012] Add files matching search pattern to archive. e[aqty] Extract files matching search pattern from archive. x[aqty] Extract files matching search pattern from archive using path information stored in archive. l[f] List files currently in archive. d[q] Delete files matching search pattern from archive. If archive does not contain any files after deletion it is removed. f[sdqemr012] Freshen files in archive. All files matching search pattern and newer than version already in archive are updated to archive. u[sdqemr012] Update files to archive. All files matching search pattern that are newer than version already in archive or are not yet in archive are updated to archive. t[q] Test files in archive. OPTIONS
0,1,2 Try compression method #. More than one can be specified. Methods are: 0-CPY Simple copying of files. 1-ASC Default method using sliding window dictionary followed by arithmetic coder. Offers quite good compression on wide variety of file types. 2-HSC Compression method based on finite context model and arithmetic coder. Quite slow for binary data, but offers very good compression especially for longer text files. y Assume answer yes on all questions. t Touch files when extracting. Sets file times to current machine time. r Recurse through subdirectories while searching for files matching search pattern. f Full listing of stored file information. m Move files when archiving. Files are removed from disk after they are successfully written to archive. a Set system specific file attributes when extracting files. s Find special files when archiving. e Do not store pathname information. q Quiet operation. d Make separate entries for directories. Saves information about empty directories, directory attributes etc. in archive. AUTHOR
This manual page was written by Mikhail Gusarov <dottedmag@dottedmag.net> for Debian GNU/Linux system (but may be used by others). ha 0.999p 3 Jul 2008 ha(1)
All times are GMT -4. The time now is 04:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy