Sponsored Content
Top Forums Shell Programming and Scripting Need help understanding this script. Post 302466184 by Scrutinizer on Monday 25th of October 2010 09:21:01 PM
Old 10-25-2010
It tries to rename any file with 2-2-4 digit date in the name and replace that date with a new date, but it contains an error as the dot should not be there.
It use parameter expansion to accomplish this.
Code:
newdate=12-10-1995
for file in *[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]*
do
  mv "$file" "${file%[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]*}$newdate${file#*[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]}"
done

And it is better to put double quotes there.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help understanding script command

We use a UNIX-based system (Lawson) at work and I was given this command to request a data extract from the db admin. The only thing I really understand is the last line as it appears to be joining the files created from the first three lines into one. Is there anyone who can help me breakdown the... (4 Replies)
Discussion started by: KGee
4 Replies

2. Shell Programming and Scripting

Help understanding a script

Hello everybody, Can anybody tell me of what "~" refers to in the below code snippet. lsvg $vgNAME | awk 'BEGIN {freeDISK=1} {if (($4 ~ /PP/ && $5 ~ /SIZE/) || ($4 ~ /FREE/ && $5 ~ /PPs/)) {freeDISK *= $6 }} END {print freeDISK*1024 }' Thanks in advance, (6 Replies)
Discussion started by: tenderfoot
6 Replies

3. Shell Programming and Scripting

Need help for understanding of script

# sub: find block (in cols), return line-numbers (begin-end) or 0 if notfound sub findb{ my ($exp1,$col1,$exp2,$col2)= @_; # $exp = expression to find, $col - column to search in my $cnt=0; my ($val1,$val2); my ($beg,$end); for($cnt=1;$cnt<=65536;$cnt++){ $val1 =... (3 Replies)
Discussion started by: suvenduperl
3 Replies

4. UNIX for Advanced & Expert Users

understanding awk in this script

i am analyzing a query written by another developer ,need to understand part of script am looking at a code ..and it converts comma files to pipe delimited and also takes away quotes from any columns, source field format: 2510,"Debbie",NewYork changes to target: 2510|Debbie|NewYork ... (1 Reply)
Discussion started by: coolrock
1 Replies

5. UNIX for Dummies Questions & Answers

help with understanding script

i am trying to understand this script example. the text does not explain it. can someone tell me briefly what each of the functions do. any help will be appreciated. #!/bin/bash killtree() { local _pid=$1 local _sig=${2-TERM} for _child in $(ps -o pid --no-headers --ppid... (1 Reply)
Discussion started by: iluvsushi
1 Replies

6. Shell Programming and Scripting

Help understanding the script

Hi Guys, I am new to scripting , I am trying to rebuild a script based on an old script. Can someone help me figure out what the script is doing? This is only a part of the script. I am looking to interpret these two points in the scripts:- 1) test=`echo $?` while I do not... (3 Replies)
Discussion started by: rajsan
3 Replies

7. Shell Programming and Scripting

Help--understanding the script

Hi, New to this forum, as well as to unix scripting..need help to understand below script ... sendNotice_sp() { ATTACH=${LNXLOG:-} if ; then if ; then mail -s "$ERR_MSG" $ERR_EMAIL_TO < $ATTACH fi else mail -s "$ERR_MSG" $ERR_EMAIL_TO < /dev/null fi } afaik this is sm kind of... (6 Replies)
Discussion started by: gnnsprapa
6 Replies

8. Shell Programming and Scripting

Help understanding the script

Could someone please help me in understanding the code below: #!/usr/bin/ksh Month=`date|cut -c5-7` Day=`date|cut -c9-10` Year=`date|cut -c27-28` Rom2Jul() { case $Month in Feb) Day=$(( $Day+31 ));; Mar) Day=$((... (27 Replies)
Discussion started by: hasn318
27 Replies

9. UNIX for Beginners Questions & Answers

Shall script use and understanding

Below script is called as Reducer, I am not sure how it work, can some expert explain me what this script does as i am a beginner. inputfile: hi hi how are are you code: #!/bin/bash lastkey=""; -- what does this mean, because i saw in debug mode it is taking value as hi count=0;... (13 Replies)
Discussion started by: mirwasim
13 Replies

10. UNIX for Beginners Questions & Answers

Understanding a script for sum

Hello, How come the following script adds each numeric value to a total sum ? x=$1 func() { for i in $1 $2 $3; do let x= $x+$i done } func "8 8 8" 9 9 echo $x A.How the program sums the string "8 8 8" if it`s only the first field value ($1)? B.If we define x to be $1... (3 Replies)
Discussion started by: uniran
3 Replies
GIT-IMPORT-DSC(1)					      git-buildpackage Manual						 GIT-IMPORT-DSC(1)

NAME
git-import-dsc - Import Debian packages into a Git repository SYNOPSIS
git-import-dsc [ --verbose ] [ --upstream-branch=branch_name ] [ --debian-branch=branch_name ] [ --[no-]sign-tags ] [ --keyid=gpg-keyid ] [ --debian-tag=tag-format ] [ --upstream-tag=tag-format ] [ --filter=pattern ] [ --[no-]pristine-tar ] [ --download ] [ --allow-same-versions ] [ --author-is-committer ] [ --author-date-is-committer-date ] debian-source.dsc git-import-dsc [ options ] --download [ --[no-]allow-unauthenticated ] URL | source-package DESCRIPTION
git-import-dsc imports a Debian source package into a Git repository, notes the package version in the commit logs, and commits the change. All information, including package name, version, Debian diffs, and upstream source is automatically detected from the source package. OPTIONS
--upstream-branch=branch_name The branch in the Git repository the upstream sources are put onto. Default is upstream. --debian-branch=branch_name The branch in the Git repository the debian sources are put onto. Default is master. --verbose -v verbose execution --[no-]sign-tags GPG sign all created tags --keyid=gpg-keyid use this keyid for gpg signing tags --debian-tag=tag-format use this tag format when tagging Debian versions, default is debian/%(version)s --upstream-tag=tag-format use this tag format when tagging upstream versions, default is upstream/%(version)s --filter=pattern filter out files glob-matching pattern. Can be given multiple times. --pristine-tar generate pristine-tar delta file --download Download the source package instead of looking for it in the local file system. The argument can either be a source-package name or an URL. The former uses apt-get to download the source while the later uses dget. --allow-unauthenticated Whether to skip signature verification on downloads. --allow-same-version Allow to import a package with the same debian version. --author-is-committer When importing the Debian patch, use the author identity as comitter identity. --author-date-is-committer-date When importing the Debian patch, use the author date as comitter date. Warning: Git will subtly misbehave if the committer date of a commit is not later than or equal to all its parents. CONFIGURATION FILES
Several gbp.conf files are parsed to set defaults for the above commandline arguments. See the [XRef to GBP.MAN.GBP.CONF] manpage for details. SEE ALSO
git-import-dscs(1), git-buildpackage(1), git-import-orig(1), git-dch(1), apt-get(1), dget(1), gbp.conf(5), debuild(1), git(1), pristine- tar(1), The Git-Buildpackage Manual <URL:file:///usr/share/doc/git-buildpackage/manual-html/index.html> AUTHOR
Guido Guenther <agx@sigxcpu.org> 01 June 2012 GIT-IMPORT-DSC(1)
All times are GMT -4. The time now is 11:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy