Sponsored Content
Top Forums Shell Programming and Scripting Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names Post 302220060 by danmero on Wednesday 30th of July 2008 09:46:17 PM
Old 07-30-2008
You can use the file time, if staging is empty move the oldest xml file from exports to staging.
Code:
[ "$(ls -A staging)" ] || mv /exports/$(ls -t /exports/*.xml | tail -1) /staging/

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding the oldest file

Hi:- I need help with a script I need to modify: - what's the best/easiest way to find out the oldest file in a directory and then move this file to another directory? Thanks, (5 Replies)
Discussion started by: janet
5 Replies

2. Shell Programming and Scripting

Finding the oldest file in a particular directory

Hi all, I am a newbie to scripting and I need your help regarding finding the oldest file in a particular directory. My intention is to remove that oldest file. Are there any options available with the "find" command to do this.. Thanks in advance for your help Pavan (4 Replies)
Discussion started by: pavan_movva
4 Replies

3. UNIX and Linux Applications

Finding the oldest file in a directory without ls

I am trying to determine the oldest and most recent files in a huge directory. I am using an ls -tr statement outside my find statement. The directory is too big and I am getting an "arg list too long" error. Is there something I can put in my find statement that doesn't create a list to... (2 Replies)
Discussion started by: hiyofjord
2 Replies

4. Shell Programming and Scripting

Need help in finding filesize , moving file , gzipping file

Hi , Please help with the following questions 1) how can i find size of a file ? i have written du -k $flname > s1 . Is this right ? Any other better suggeastions ? 2) how do I use mv command for moving the file ? I need the syntax with some examples 3) Command for printing the total... (1 Reply)
Discussion started by: Learning!
1 Replies

5. Shell Programming and Scripting

Parsing Log File Based on Date & Error

I'm still up trying to figure this out and it is driving me nuts. I have a log file which has a basic format of this... 2010-10-10 22:25:42 Init block 'UA Deployment Date': Dynamic refresh of repository scope variables has failed. The ODBC function has returned an error. The database... (4 Replies)
Discussion started by: k1ko
4 Replies

6. Shell Programming and Scripting

Sorting and moving file sequence with gaps

Hello, I have lots of sequentially numbered files which make up an image sequence. I'm trying to do two things with it: #1: Find gaps in the sequence and move each range of sequencial files into their own subfolder. #2: Designate a starting point (file) and move every 24th file into... (4 Replies)
Discussion started by: ex_H
4 Replies

7. Shell Programming and Scripting

Sorting file based on names

Hi I have some files in directory and the names of files are like jnhld_15233_2010-11-23 jnhld_15233_2007-10-01 jnhld_15233_2001-05-04 jnhld_15233_2011-11-11 jnhld_15233_2005-06-07 jnhld_15233_2000-04-01 ..etc How can i sort these files based on the date in the file name so that ... (4 Replies)
Discussion started by: morbid_angel
4 Replies

8. Shell Programming and Scripting

sorting file names with hyphen and underscore

Hi, I have two types of file names filename1_12345 or filename1-12345 at the same time I have second type filename2-12345 in a txt file. I am trying to write awk script that will sort these names with below pattern ALL file names like filename1_12345 and filename1-12345 will go to... (1 Reply)
Discussion started by: rider29
1 Replies

9. Shell Programming and Scripting

Moving files only by oldest file one at a time

Hi I am want to create a script where the file gets moved from the current folder to a folder transfer based on the oldest first. This script should run one file at a time using a loop. I want it as a loop because I want to do some processing while I have one file. Can anyone guide me on this? (2 Replies)
Discussion started by: chamajid
2 Replies

10. Shell Programming and Scripting

File Move & Sort by Name - Kick out Bad File Names & More

I have a dilemma, we have users who are copying files to "directory 1." These images have file names which include the year it was taken. I need to put together a script to do the following: Examine the file naming convention, ensuring it's the proper format (e.g. test-1983_filename-123.tif)... (8 Replies)
Discussion started by: Nvizn
8 Replies
GIT-REMOTE(1)							    Git Manual							     GIT-REMOTE(1)

NAME
       git-remote - Manage set of tracked repositories

SYNOPSIS
       git remote [-v | --verbose]
       git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
       git remote rename <old> <new>
       git remote remove <name>
       git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
       git remote set-branches [--add] <name> <branch>...
       git remote get-url [--push] [--all] <name>
       git remote set-url [--push] <name> <newurl> [<oldurl>]
       git remote set-url --add [--push] <name> <newurl>
       git remote set-url --delete [--push] <name> <url>
       git remote [-v | --verbose] show [-n] <name>...
       git remote prune [-n | --dry-run] <name>...
       git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]

DESCRIPTION
       Manage the set of repositories ("remotes") whose branches you track.

OPTIONS
       -v, --verbose
	   Be a little more verbose and show remote url after name. NOTE: This must be placed between remote and subcommand.

COMMANDS
       With no arguments, shows a list of existing remotes. Several subcommands are available to perform operations on the remotes.

       add
	   Adds a remote named <name> for the repository at <url>. The command git fetch <name> can then be used to create and update
	   remote-tracking branches <name>/<branch>.

	   With -f option, git fetch <name> is run immediately after the remote information is set up.

	   With --tags option, git fetch <name> imports every tag from the remote repository.

	   With --no-tags option, git fetch <name> does not import tags from the remote repository.

	   By default, only tags on fetched branches are imported (see git-fetch(1)).

	   With -t <branch> option, instead of the default glob refspec for the remote to track all branches under the refs/remotes/<name>/
	   namespace, a refspec to track only <branch> is created. You can give more than one -t <branch> to track multiple branches without
	   grabbing all branches.

	   With -m <master> option, a symbolic-ref refs/remotes/<name>/HEAD is set up to point at remote's <master> branch. See also the set-head
	   command.

	   When a fetch mirror is created with --mirror=fetch, the refs will not be stored in the refs/remotes/ namespace, but rather everything
	   in refs/ on the remote will be directly mirrored into refs/ in the local repository. This option only makes sense in bare repositories,
	   because a fetch would overwrite any local commits.

	   When a push mirror is created with --mirror=push, then git push will always behave as if --mirror was passed.

       rename
	   Rename the remote named <old> to <new>. All remote-tracking branches and configuration settings for the remote are updated.

	   In case <old> and <new> are the same, and <old> is a file under $GIT_DIR/remotes or $GIT_DIR/branches, the remote is converted to the
	   configuration file format.

       remove, rm
	   Remove the remote named <name>. All remote-tracking branches and configuration settings for the remote are removed.

       set-head
	   Sets or deletes the default branch (i.e. the target of the symbolic-ref refs/remotes/<name>/HEAD) for the named remote. Having a
	   default branch for a remote is not required, but allows the name of the remote to be specified in lieu of a specific branch. For
	   example, if the default branch for origin is set to master, then origin may be specified wherever you would normally specify
	   origin/master.

	   With -d or --delete, the symbolic ref refs/remotes/<name>/HEAD is deleted.

	   With -a or --auto, the remote is queried to determine its HEAD, then the symbolic-ref refs/remotes/<name>/HEAD is set to the same
	   branch. e.g., if the remote HEAD is pointed at next, "git remote set-head origin -a" will set the symbolic-ref refs/remotes/origin/HEAD
	   to refs/remotes/origin/next. This will only work if refs/remotes/origin/next already exists; if not it must be fetched first.

	   Use <branch> to set the symbolic-ref refs/remotes/<name>/HEAD explicitly. e.g., "git remote set-head origin master" will set the
	   symbolic-ref refs/remotes/origin/HEAD to refs/remotes/origin/master. This will only work if refs/remotes/origin/master already exists;
	   if not it must be fetched first.

       set-branches
	   Changes the list of branches tracked by the named remote. This can be used to track a subset of the available remote branches after the
	   initial setup for a remote.

	   The named branches will be interpreted as if specified with the -t option on the git remote add command line.

	   With --add, instead of replacing the list of currently tracked branches, adds to that list.

       get-url
	   Retrieves the URLs for a remote. Configurations for insteadOf and pushInsteadOf are expanded here. By default, only the first URL is
	   listed.

	   With --push, push URLs are queried rather than fetch URLs.

	   With --all, all URLs for the remote will be listed.

       set-url
	   Changes URLs for the remote. Sets first URL for remote <name> that matches regex <oldurl> (first URL if no <oldurl> is given) to
	   <newurl>. If <oldurl> doesn't match any URL, an error occurs and nothing is changed.

	   With --push, push URLs are manipulated instead of fetch URLs.

	   With --add, instead of changing existing URLs, new URL is added.

	   With --delete, instead of changing existing URLs, all URLs matching regex <url> are deleted for remote <name>. Trying to delete all
	   non-push URLs is an error.

	   Note that the push URL and the fetch URL, even though they can be set differently, must still refer to the same place. What you pushed
	   to the push URL should be what you would see if you immediately fetched from the fetch URL. If you are trying to fetch from one place
	   (e.g. your upstream) and push to another (e.g. your publishing repository), use two separate remotes.

       show
	   Gives some information about the remote <name>.

	   With -n option, the remote heads are not queried first with git ls-remote <name>; cached information is used instead.

       prune
	   Deletes stale references associated with <name>. By default, stale remote-tracking branches under <name> are deleted, but depending on
	   global configuration and the configuration of the remote we might even prune local tags that haven't been pushed there. Equivalent to
	   git fetch --prune <name>, except that no new references will be fetched.

	   See the PRUNING section of git-fetch(1) for what it'll prune depending on various configuration.

	   With --dry-run option, report what branches will be pruned, but do not actually prune them.

       update
	   Fetch updates for a named set of remotes in the repository as defined by remotes.<group>. If a named group is not specified on the
	   command line, the configuration parameter remotes.default will be used; if remotes.default is not defined, all remotes which do not
	   have the configuration parameter remote.<name>.skipDefaultUpdate set to true will be updated. (See git-config(1)).

	   With --prune option, run pruning against all the remotes that are updated.

DISCUSSION
       The remote configuration is achieved using the remote.origin.url and remote.origin.fetch configuration variables. (See git-config(1)).

EXAMPLES
       o   Add a new remote, fetch, and check out a branch from it

	       $ git remote
	       origin
	       $ git branch -r
		 origin/HEAD -> origin/master
		 origin/master
	       $ git remote add staging git://git.kernel.org/.../gregkh/staging.git
	       $ git remote
	       origin
	       staging
	       $ git fetch staging
	       ...
	       From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
		* [new branch]	    master     -> staging/master
		* [new branch]	    staging-linus -> staging/staging-linus
		* [new branch]	    staging-next -> staging/staging-next
	       $ git branch -r
		 origin/HEAD -> origin/master
		 origin/master
		 staging/master
		 staging/staging-linus
		 staging/staging-next
	       $ git checkout -b staging staging/master
	       ...

       o   Imitate git clone but track only selected branches

	       $ mkdir project.git
	       $ cd project.git
	       $ git init
	       $ git remote add -f -t master -m master origin git://example.com/git.git/
	       $ git merge origin

SEE ALSO
       git-fetch(1) git-branch(1) git-config(1)

GIT
       Part of the git(1) suite

Git 2.17.1							    10/05/2018							     GIT-REMOTE(1)
All times are GMT -4. The time now is 08:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy