04-29-2009
I don't know if it's the best way, but I'd setup a script with a line like:
monthnum=0
for month in (Jan Feb Mar Apr); do
monthnum=$(($monthnum+1))
sed -e "s/'$month'/'$monthnum/" <infile >outfile
done
Thats off the top of my head, obviously you'll need to write the whole script
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I get a text file with 70+ columns (seperated by Tab) and about 10000 rows. The 58th Column is all numbers. But sometimes 58th columns has "/xxx=##" after the numeric data. I want to truncate this string using the script. Any Ideas...:confused: (3 Replies)
Discussion started by: gagansharma
3 Replies
2. UNIX for Dummies Questions & Answers
Hi all,
I have a script that scan files, find old templet and replace it with new one.
#!/bin/ksh
file_name=$1
old_templet=$2
new_templet=$3
# Loop through every file like this
for file in file_name
do
cat $file | sed "s/old_templet/new_templet/g" > $file.new
#do a global searce and... (8 Replies)
Discussion started by: amir_yosha
8 Replies
3. UNIX for Dummies Questions & Answers
Hey, I want to have a C program which, for an existing file supplied by the command line argument (E.g. File1.txt) replaces all the occurrences of the words:
"We” or “we” by “I”
“a” by “the”
“A” by “The”.
Then print the replaced file. All other characters of the file are to be left... (1 Reply)
Discussion started by: IwishIknewC
1 Replies
4. UNIX for Dummies Questions & Answers
I want to carry out search & replace for the paths mentioned in the file with the help of vi.
'abc/' to be replaced by 'abc/data'
When I use command in vi as below -
%s/abc//abc/data/g
it gives me an error.
How we should deal with '/' part in string for vi search & replace?
... (6 Replies)
Discussion started by: videsh77
6 Replies
5. Shell Programming and Scripting
Looking for a way using sed/awk/perl to replace port numbers in a file with an incrementing number. The original file looks like...
Host cmg-iqdrw3p4
LocalForward *:9043 localhost:9043
Host cmg-iqdro3p3a
LocalForward *:10000 localhost:10000
Host cmg-iqdro3p3b
LocalForward... (2 Replies)
Discussion started by: treadwm
2 Replies
6. Shell Programming and Scripting
find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g'
this is simple logic to find and replace in multiple files & folders
Hope this helps.
Thanks
Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies
7. Shell Programming and Scripting
Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ?
The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories.
So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies
8. Shell Programming and Scripting
Hi All,
i am trying to replace a string & its current value (P_JOBID =1000 for eg) in a file with a new value(P_JOBID =2000) through sed command.
File name : A.txt
Command I am trying :
`cat $path/A.txt | grep ${P_JOBID} | sed -e s/P_JOBID=/P_JOBID="$JobID"/g`
Output Expected :... (5 Replies)
Discussion started by: dsfreddie
5 Replies
9. UNIX for Dummies Questions & Answers
Hi
I am looking to rename the contents of this dir, each one with a new timestamp, interval of a second for each so it the existing format is on lhs and what I want is to rename each of these to what is on rhs..hopefully it nake sense
CDR.20060505.150006.gb CDR.20121211.191500.gb... (3 Replies)
Discussion started by: rob171171
3 Replies
10. Shell Programming and Scripting
Hi,
Here's my dilemma.
I need to replace the string Sept_2012 to Oct_2012 in all *config.py files within the current directory and below directories
Is this possible?
Also I am trying to find all instances of the string Sept_2012 within files in the current directory and below
I have... (13 Replies)
Discussion started by: pure_jax
13 Replies
cal(1) User Commands cal(1)
NAME
cal - display a calendar
SYNOPSIS
cal [ [month] year]
DESCRIPTION
The cal utility writes a Gregorian calendar to standard output. If the year operand is specified, a calendar for that year is written. If
no operands are specified, a calendar for the current month is written.
OPERANDS
The following operands are supported:
month Specify the month to be displayed, represented as a decimal integer from 1 (January) to 12 (December). The default is the current
month.
year Specify the year for which the calendar is displayed, represented as a decimal integer from 1 to 9999. The default is the current
year.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cal: LANG, LC_ALL, LC_CTYPE, LC_TIME,
LC_MESSAGES, and NLSPATH.
TZ Determine the timezone used to calculate the value of the current month.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWesu |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
calendar(1), attributes(5), environ(5), standards(5)
NOTES
An unusual calendar is printed for September 1752. That is the month 11 days were skipped to make up for lack of leap year adjustments. To
see this calendar, type:
cal 9 1752
The command cal 83 refers to the year 83, not 1983.
The year is always considered to start in January.
SunOS 5.10 1 Feb 1995 cal(1)