Tag Info

New answers tagged

1

The issue was resolved by putting the path before the CLT iwgetwfobj. Thanks for the help.


0

If the source string is held in variable s, then you could just use printf and substr ie printf("%2d-%2d-%4d %2d:%2d:%2d", substr(s,7,2), substr(s,5,2), substr(s,1,4), substr(s,9,2), substr(s,11,2), substr(s,13,2) )


1

Next will convert any field of 14 digits: awk -F, ' function form(E){ $E=substr($E,1,4) "-" substr($E,5,2) "-" substr($E,7,2) " "\ substr($E,9,2) ":" substr($E,11,2) ":" substr($E,13) } { for(i=1;i<=NF;i++) if($i ~ /[0-9]{14}/) form(i) print }' OFS=, mdn.txt ...


3

awk 'BEGIN{ FS=OFS="," n=split("4,5,7,13,19", f) # array of input field numbers } { for(i=1; i<=n; i++) if($f[i]) $f[i] = dconv($f[i]); print } function dconv(x) { YY=substr(x, 1, 4) mm=substr(x, 5, 2) dd=substr(x, 7, 2) hh=substr(x, 9, 2) nn=substr(x,11, 2) ss=substr(x,13, 2) ...


2

GNU date -d option is expecting the provided date to be in "locale independent format", i.e. POSIX which essentially means US format as far as xx/yy/zz dates are concerned.


0

Your problem is not with Jul, but with /, so remove them using for example parameter substitution mechanism: echo "Please enter the date: " read X a=$(date --date="${X//\//-}" '+%d-%b-%y') echo "$a" Please note that your variable assignment was also wrong (there must not be space after =) and command substitution should be enclosed with $().


1

If $x contains 14/Jul/2015, then use this: date -d "${x//\//-}" '+%d-%m-%Y' It will print: 14-07-2015 The date utillity doesn't understand the slash separated string, so you have to remove it and replace it with a dash (-).


4

I highly recommend dateutils for things like this. (yum install dateutils on Fedora 21+ or CentOS/RHEL 7 with EPEL.) Then, just do: dateround today sunday You can use "today" or replace with an actual date: $ dateround 2015-08-30 saturday 2015-09-05 If you need the input date to be in a specific format, like your 30-AUG-2015, you can use the -i or ...


1

I presume from what you tried that you want a single command.  I couldn’t find one, but I adapted this answer to do what you want: # Assume that date1 is already set to "30-AUG-2015" try_date="$date1" while [ "$(date --date="$try_date" +"%A")" != Saturday ] do try_date=$(date --date="$try_date + 1 day" +"%d-%b-%Y") done date2="$try_date" echo "$date2" ...


3

With ksh93: $ LC_ALL=C ksh93 -c 'printf "%(%c)T\n" "30-Aug-2015 Saturday"' Sat Sep 5 00:00:00 2015 Note that if the date is a Saturday, then it will return that same day, if you want the next Saturday, make it: LC_ALL=C printf "%(%c)T\n" "30-Aug-2015 tomorrow Saturday" Replace %c with the strftime spec you want: $ LC_ALL=C printf "%(%d-%b-%Y)T\n" ...


1

ISO 9660 ? Try dd if=/dev/sr0 bs=1 skip=33581 count=17 | hexdump -C Example output: 00000000 32 30 31 32 30 38 32 33 31 37 31 33 34 37 30 30 |2012082317134700| 00000010 00 |.|


0

With zsh and (.m[-|+]n) glob-qualifiers: print -rl -- *(.m90) will list files modified exactly 90 days ago, print -rl -- *(.m-90) will list files modified in the last 90 days, print -rl -- *(.m-100m+80) will list files modified between 80 and 100 days ago.


1

With zsh you could use the function age to print only the names of files that have been modified on a certain date: autoload age print -rl -- *.php(.e:age 2011/02/08:) or, if you want to search recursively: autoload age setopt extendedglob print -rl -- **/*.php(.e:age 2011/02/08:)


3

With bash-4.2 or above: printf '%(%F %T)T\n' 1234567890 (where %F %T is the strftime()-type format) That syntax is inspired from ksh93. In ksh93 however, the argument is taken as a date expression where various and hardly documented formats are supported. For a Unix epoch time, the syntax in ksh93 is: printf '%(%F %T)T\n' '#1234567890' ksh93 however ...


2

With zsh you could use the strftime builtin: strftime format epochtime Output the date denoted by epochtime in the format specified. e.g. zmodload zsh/datetime strftime '%A, %d %b %Y' 1234567890 Saturday, 14 Feb 2009



Top 50 recent answers are included