Sponsored Content
Top Forums Shell Programming and Scripting Concatenation in awk not working Post 302774071 by neutronscott on Friday 1st of March 2013 05:50:15 AM
Old 03-01-2013
You're just trying to prepend the date to filename?

Code:
date=$(date +'%d%m%y%k%M%S')
for file in *myfile*.log; do
  mv "$file" "${date}${file}"
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenation

What is syntax for String concatenation? I have $1 as directory. $var is some variable value '/' String value. How do I have to concatenate if I have to run utility - util $1 followed by '/' followed by $var There is no space between these three. (2 Replies)
Discussion started by: videsh77
2 Replies

2. Shell Programming and Scripting

cannot get logic for concatenation awk

Hello friends, I have a problem in printing an array.. Example if my array line contains 4 elements like following line=0002 , line=202200, line=200002, line= 300313 Now one = sprintf line line line line will concatenate my whole array to one. But I am not sure about the... (7 Replies)
Discussion started by: user_prady
7 Replies

3. Shell Programming and Scripting

awk not working for me.

Hi All, I have a server.xml file which looks something like. <Connector port="8443" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100"... (2 Replies)
Discussion started by: nua7
2 Replies

4. Shell Programming and Scripting

String concatenation not working in a loop

Hi, First post, so I hope someone can help me with this weirdness :) I have a number files with some rows of information I want to extract, at the same time I want to add to a string some details from the file. I have found two different ways of looping over rows in a file, but one method... (5 Replies)
Discussion started by: LostInTheWoods
5 Replies

5. Shell Programming and Scripting

Awk concatenation in different lines

Hi All I have the data as id-number 01 name-id x0 input-id x0 output-id x0 name-id x0 input-id x0 output-id x0 name-id x0 input-id x0 output-id x0 id-number 02 name-id x0 input-id x0 output-id x0 name-id x0 input-id x0 output-id x0 name-id x0 input-id x0 output-id x0 . . I... (4 Replies)
Discussion started by: posner
4 Replies

6. UNIX for Advanced & Expert Users

Awk expressions working & not working

Hi, Putting across a few awk expressions. Apart from the last, all of them are working. echo a/b/c | awk -F'/b/c$' '{print $1}' a echo a/b/c++ | awk -F'/b/c++' '{print $1}' a echo a/b/c++ | awk -F'/b/c++$' '{print $1}' a/b/c++ Request thoughts on why putting a '$' post double ++... (12 Replies)
Discussion started by: vibhor_agarwali
12 Replies

7. UNIX for Dummies Questions & Answers

awk for concatenation of column values

Hello, I have a table as shown below. I want to concatenate values in col2 and col3 based on a value in col4. 1 X Y A 3 Y Z B 4 A W B 5 T W A If col4 is A, then I want to concatenate col3 with itself. Otherwise it should concateneate col2 with col3. 1 X Y YY 3 Y Z YZ... (10 Replies)
Discussion started by: Gussifinknottle
10 Replies

8. Shell Programming and Scripting

awk help : if then else not working!

Hi All, This code is not working when trying with "else" : Am I missing something, uptime|sed 's/,/ /g' | awk '{ if ($10 >1) { print ( " :: UPTIME GT 1 : ALERT" )} ;else print "OK" }' Getting this error: syntax error The source line is 1. The error context is { if... (4 Replies)
Discussion started by: rveri
4 Replies

9. Shell Programming and Scripting

Awk: System command not working in awk

Hi, I have around 10 files in a folder in which I want to change the file format from tab(\t) to pipe(|) with some changes in the fields as well. Below is the code, while tmp file is getting generated but move command is not working, please help Following is the code awk -F"\t" '{print... (2 Replies)
Discussion started by: siramitsharma
2 Replies

10. Shell Programming and Scripting

awk concatenation issue - SQL generation

Greetings Experts, I have an excel file and I am unable to read it directly into awk (contains , " etc); So, I cleansed and copied the data into notepad. I need to generate a script that generates the SQL. Requirement: 1. Filter and select only the data that has the "mapping" as "direct"... (4 Replies)
Discussion started by: chill3chee
4 Replies
DATE(1) 						      General Commands Manual							   DATE(1)

NAME
date - print or set the date and time SYNOPSIS
date [-qsu] [[MMDDYY]hhmm[ss]] [+format] OPTIONS
-q Read the date from stdin -s Set the time (implicit for -q or a date string) -u Print the date as GMT -t Use this number of seconds instead of current time EXAMPLES
date # Print the date and time date 0221921610 # Set date to Feb 21, 1992 at 4:10 p.m. DESCRIPTION
With the -q flag or a numeric argument, date sets the GMT time and date. MMDDYY refers to the month, day, and year; hhmmss refers to the hour, minute and second. Each of the six fields must be exactly two digits, no more and no less. date always display the date and time, with the default format for the system. The -u flag request GMT time instead of local time. A format may be specified with a + followed by a printf-like string with the following options: %% % character %A Name of the day %B Name of the month %D mm/dd/yy %H Decimal hour on 2 digits %I Decimal hour modulo 12 on 2 digits %M Decimal minute on 2 digits %S Decimal seconds on 2 digits %T HH:MM:SS %U Decimal week number, Sunday being first day of week %W Decimal week number, Monday being first day of week %X Same as %T %Y Decimal year on 4 digits %Z Time Zone (if any) %a Abbreviated name of the day %b Abbreviated name of the month %c Appropriate date & time (default format) %d Decimal day of the month on 2 digits %e Same as %d, but a space replaces leading 0 %h Same as %b %j Decimal dey of the year on 3 digits %m Decimal month on 2 digits %n Newline character %p AM or PM %r 12-hour clock time with AM/PM %s Number of seconds since the epoch %t Tab character %w Decimal day of the week (0=Sunday) %x Same as %D %y Decimal year on 2 digits SEE ALSO
time(2), ctime(3), readclock(8). DATE(1)
All times are GMT -4. The time now is 10:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy