This is a repost from stackoverflow since someone told me my question was off-topic for the site and I got the following answers:
Considering your file ends with a newline:
head -1 Dataset1.csv | tr '[:lower:]' '[:upper:]' > Dataset1_new.csv ; tail -$(( $(wc -l Dataset1.csv | cut -d ' ' -f 8) - 1 )) Dataset1.csv > Dataset1_new.csv
head -1 Dataset1.csv | tr '[:lower:]' '[:upper:]'
: takes the first line of your file, transforms it to uppercase & outputs it on stdout
> Dataset1_new.csv
: redirects the output to a new file called Dataset1_new.csv
tail -$(( $(wc -l Dataset1.csv | cut -d ' ' -f 8) - 1 ))
Dataset1.csv: outputs the rest of the lines
> Dataset1_new.csv:
again, redirects the output to our Dataset1_new.csv file
You can do it with GNU sed:
$ sed -i -e '1 s/\(.*\)/\U\1/' input.csv
You can also use awk for this purpose:
awk -i.bak 'NR==1{ print toupper($0) }NR>1' Dataset1.csv
Explanations:
awk will take a backup of your csv file and then for the first line (NR==1) will change the whole line $0 to uppercase then for the rest of the file (NR>1) will do its default action which is printing the line.