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
ii(1)							      General Commands Manual							     ii(1)

NAME
ii - irc it or irc improved DESCRIPTION
ii is a minimalistic FIFO and filesystem based IRC client. It creates an irc directory tree with server, channel and nick name directo- ries. In every directory a FIFO file (in) and and normal file (out) is placed. This will be for example ~/irc/irc.freenode.net/. The in file is used to communicate with the servers and the out files includes the server messages. For every channel and every nick name there will be new in and out files. The basic idea of this is to be able to communicate with an IRC server with basic command line tools. For example if you will join a channel just do echo "/j #channel" > in and ii creates a new channel directory with in and out file. SYNOPSIS
ii [-s servername] [-p port] [-k password] [-i prefix] [-n nickname] [-f realname] OPTIONS
-s servername lets you override the default servername (irc.freenode.net) -p port lets you override the default port (6667) -k password lets you use a password to authenticate your nick on the server (be aware of the problem that this is visible in the process list, if you don't want this use a query to submit your password) -i prefix lets you override the default irc path (~/irc) -n nickname lets you override the default nick ($USER) -f realname lets you specify your real name associated with your nick DIRECTORIES
~/irc In this directory the irc tree will be created. In this directory you will find a directory for your server (default: irc.freen- ode.net) in which the FIFO and the output file will be stored. If you join a channel a new directory with the name of the channel will be created in the ~/irc/$servername/ directory. COMMANDS
/a [<message>] mark yourself as away /j #channel/nickname [<message>] join a channel or open private conversation with user /l #channel/nickname leave a channel or query /n nick change the nick name /t topic set the topic of a channel Everything which is not a command will simply be posted into the channel or to the server. So if you need /who just write /WHO as described in the RFC to the server in FIFO. out file usage Write wrappers, pagers or use your tools of choice to display the out file contents (loco, multitail, etc.). CONTACT
Write to ii (at) modprobe (dot) de for suggestions, fixes, 7|-|>< ;) etc. AUTHORS
Copyright (C) 2005-2006 by Anselm R. Garbe <garbeam (at) gmail (dot) com> and Copyright (C) 2005-2008 by Nico Golde <nico (at) ngolde (dot) de> SEE ALSO
echo(1), tail(1), ii(1)
All times are GMT -4. The time now is 01:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy