Convert the first letter of each line to uppercase


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert the first letter of each line to uppercase
# 1  
Old 11-04-2010
Convert the first letter of each line to uppercase

Hi,
I have the following file:
Code:
/* ----------------- ADP2DAILY_Box ----------------- */
insert_job: ADP2DAILY_Box
job_type: b
owner: mbprwork
permission: gx,wx
date_conditions: 1
days_of_week: mo,tu,we,th,fr
exclude_calendar: mtg_holidays
start_times: "1:00"
description: "Process Daily New pools agency data"
alarm_if_fail: 1
/* ----------------- ADP2DAILY_JobSetPermission ----------------- */
insert_job: ADP2DAILY_JobSetPermission
job_type: c
box_name: ADP2DAILY_Box
command: $RUNDIR/set_geo_perm_mtgrep.csh
machine: cffimtgsaslx01
owner: mbprwork
permission: gx,wx
condition: success(ADP2_4BDRunBox) and success(ADP2_9BDRunBox)
n_retrys: 1
std_out_file: > $JOBSPATH/$AUTO_JOB_NAME
std_err_file: > $ERRSPATH/$AUTO_JOB_NAME
alarm_if_fail: 1
profile: /home/MtgMdlApps/AGENCY/bin/Adp2DailyAgencyBoxEnv.sh

I want this as my output:
Code:
/* ----------------- ADP2DAILY_Box ----------------- */
Insert_job: ADP2DAILY_Box
Job_type: b
Owner: mbprwork
Permission: gx,wx
Date_conditions: 1
Days_of_week: mo,tu,we,th,fr
Exclude_calendar: mtg_holidays
Start_times: "1:00"
Description: "Process Daily New pools agency data"
Alarm_if_fail: 1
/* ----------------- ADP2DAILY_JobSetPermission ----------------- */
Insert_job: ADP2DAILY_JobSetPermission
Job_type: c
Box_name: ADP2DAILY_Box
Command: $RUNDIR/set_geo_perm_mtgrep.csh
Machine: cffimtgsaslx01
Owner: mbprwork
Permission: gx,wx
Condition: success(ADP2_4BDRunBox) and success(ADP2_9BDRunBox)
N_retrys: 1
Std_out_file: > $JOBSPATH/$AUTO_JOB_NAME
Std_err_file: > $ERRSPATH/$AUTO_JOB_NAME
Alarm_if_fail: 1
Profile: /home/MtgMdlApps/AGENCY/bin/Adp2DailyAgencyBoxEnv.sh

how do i achieve this in a unix shell script
# 2  
Old 11-04-2010
Code:
awk ' { $0=toupper(substr($0,1,1))substr($0,2); print } ' file

# 3  
Old 11-04-2010
Code:
# cut -c1 infile | tr [:lower:] [:upper:] >in1
# cut -c2- infile >in2
# paste in1 in2 | sed 's/\s//' >infile
# rm in1 in2

# 4  
Old 11-04-2010
Another one:
Code:
awk '$1=toupper($1)' FS= OFS= file

# 5  
Old 11-04-2010
Some sed implementations support the special \u sequence:

Code:
sed 's/./\u&/' infile

With Perl:

Code:
perl -pe's/./\u$&/' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED (or other) upper to lowercase, with first letter of first word in each sentence uppercase

The title pretty much defines the problem. I have text files that are all in caps. I would like to convert them to lowercase, but have the first letter of the first word in each sentence in uppercase. I already have SED on the server for fixing / tweaking text files, but I'm open to other... (5 Replies)
Discussion started by: dockline
5 Replies

2. Shell Programming and Scripting

Find Files and then convert them to Uppercase

Hi All, So I'm new to scripting and I've been put in a position to convert a bunch of files with specific extensions in a folder and all its subfolders to uppercase including their extension. I figure so far I could do something like this: ... ... and then input $line into another bash... (12 Replies)
Discussion started by: ideal2545
12 Replies

3. Shell Programming and Scripting

convert to uppercase in specific table

Hi All, I'm a newbie here, i'm just wondering is it possible to convert into uppercase the records in specific field? ex. table name = mytable field1 field2 field3 abd erfdF fdsfdsfsd how can i convert into uppercase the field2 using sybase? Please advise, ... (2 Replies)
Discussion started by: nikki1200
2 Replies

4. Shell Programming and Scripting

Convert lowercase to uppercase

listprocs.sh contains ps -ef | grep "swikar" 1) Write a shell script to convert an input file to all upper case. Name your shell script toupper.sh. Hint: tr ' ' ' ' will convert all lower case letters to upper case To use your script, try the following command: cat... (1 Reply)
Discussion started by: swikar
1 Replies

5. Shell Programming and Scripting

insert "_" before uppercase letter with awk

Hi, I am trying to insert a "_" character in front of capital letters in a string. For instance: HappyDaysAreHereAgain needs to become Happy_Days_Are_Here_Again I know how to do this with sed, but I am writing an awk script, which does several things. Also, I have already set FS in order... (9 Replies)
Discussion started by: kato
9 Replies

6. Shell Programming and Scripting

how to convert user input to uppercase

Hi, how to convert user input (lowercase) to uppercase in the dos batch file ? echo. SET /p user1=Enter username: SET user2=%user1%V echo. echo %user1% echo. echo %user2% echo. With Regards (7 Replies)
Discussion started by: milink
7 Replies

7. Shell Programming and Scripting

Convert to upper case first letter of each word in column 2

Hi guys, I have a file separated by ",". I´m trying to change to upper case the first letter of each word in column 2 to establish a standard format on this column. I hope somebody could help me to complete the SED or AWK script below. The file looks like this: (Some lines in column 2... (16 Replies)
Discussion started by: cgkmal
16 Replies

8. UNIX for Dummies Questions & Answers

Convert string to uppercase

i have this piece of small code that checks for *.CSV files. NUMFILES=`ls -1 *.CSV | wc -l` for filename in $(ls -1 *.CSV) do ... done it works only if the files has an uppercase of *.CSV extension. however, when there is a file of the same type but has lowercase *.csv... (1 Reply)
Discussion started by: wtolentino
1 Replies

9. Shell Programming and Scripting

sed help to convert from lowercase to uppercase and vice versa!

Hello, can sed be used to convert all letters of a file from uppercase to lowercase and vice versa?i know tr command can be used but with sed is it possible? i came up with this :- sed 'y///' file1 actually the above command is also not working! Please help me. Thanks in advance :) (6 Replies)
Discussion started by: salman4u
6 Replies

10. Shell Programming and Scripting

How convert lowercase or uppercase

It will only accept one argument where it should be upper or lowercase. if user choose to convert filnames to upper case than it should convert to upper or vice versa. if no action taken by the user then should not do anything any of the files in the current directory. (5 Replies)
Discussion started by: Alex20
5 Replies
Login or Register to Ask a Question