Changing the order of columns in a script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Changing the order of columns in a script
# 1  
Old 06-17-2008
Changing the order of columns in a script

I have the following script:
Code:
(echo -n `curl http://www.example.com/scores.txt | grep mylocation`; date +%Y%m%d%H%M%S) >> myscores.txt

This script works fine, except that it places the timestamp at the end of the file myscores.txt. How do add the timestamp as the first column and then a tab and then the myscore field?

Thanks in advance
# 2  
Old 06-17-2008
dt=`date +%Y%m%d%H%M%S`;
echo -n $dt "\t" `curl http://www.example.com/scores.txt | grep mylocation` >> myscores.txt
# 3  
Old 06-17-2008
Thanks for the prompt response. However, is this also possible to do as a one liner?

Thanks in advance
# 4  
Old 06-18-2008
yes, just join the lines together with a semi-colon
# 5  
Old 06-18-2008
Thanks again. I currently have this:
Code:
echo `date +%Y%m%d%H%M%S` `curl http://www.example.com/scores.txt | grep mylocation` >> myscores.txt

It appeared there was no need for a tab character after all.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Re-order columns

I am trying to reorder columns based on a value in a field in the attached file. Thank you :). If $11 is not equal to "unknown", then in a new text file $4, $11, $7, $13 For example, row 24 $11 is not unknown A_16_P39089234, chr10:76765556-76765615, KAT6B, 0.9337 (5 Replies)
Discussion started by: cmccabe
5 Replies

2. UNIX for Dummies Questions & Answers

Rename multiple files in shell bash, changing elements order.

Hi, I want to rename several files like this: example: A0805120817.BHN A0805120818.BHN ..... to: 20120817.0805.N 20120818.0805.N ...... How can i do this via terminal or in shell bash script ? thanks, (6 Replies)
Discussion started by: pintolcv
6 Replies

3. Shell Programming and Scripting

CSv2dat file headers and columns order

Dear all, I have a csv file which is transformed to .dat. I have an awk file which is supposing to do the mapping of the dat file. the code from the awk file is the one below. The content of the dat file is looking like this (tab separated): ODT AGE CDT CO SEX TIME ... (9 Replies)
Discussion started by: grikoss
9 Replies

4. Shell Programming and Scripting

Changing integer columns to floating decimal columns

I have a document that has 7 columns. eg. $1 $2 $3 $4 $5 $6 $7 string string string string integer integer integer The 6th and 7th columns are a mix of integers and floating decimals (with 4 decimal places). I need to convert the last 2 columns so that all... (3 Replies)
Discussion started by: kadm
3 Replies

5. Ubuntu

Changing boot order doesn't work

Hey i am running both ubuntu 10.10 and windows 7, trying to make the default boot be windows 7 instead of ubuntu but it doesn't want to work. Ive tried changing default in the grub file it didnt work, then i installed startup-manager and set windows 7 as the OS and it still boots into ubuntu. Thx... (3 Replies)
Discussion started by: Era555
3 Replies

6. UNIX for Dummies Questions & Answers

Renaming files by changing date order

I'm looking for a simple solution to rename a batch of files. All of the files in this directory start with a date in the format mm.dd.yy followed by a space and then additional descriptive text. Example: 01.21.10 742 P.xlsx 02.24.09 730 Smith.xlsx The information following the date can... (3 Replies)
Discussion started by: kreisel
3 Replies

7. Shell Programming and Scripting

Change many columns position/order

Hi everyone, Please some help over here. (I´m using cygwing) I have files with 40 columns and 2000 lines in average. I´m trying to change the order position as follow. Original columns position:... (3 Replies)
Discussion started by: cgkmal
3 Replies

8. UNIX for Dummies Questions & Answers

Changing Sequence of Columns

Hello, I might require some help here. I have a file, ITEMS with the below data : A1 20 A2 A3 B1 40 B2 B3 C1 70 C2 C3 D1 90 D2 D3 I need the output as : A2 A3 20 B2 B3 40 C2 C3 70 D2 D3 90 i.e, I need the sequence of columns to be changed and only 3 fields to be... (5 Replies)
Discussion started by: sushant172
5 Replies

9. UNIX for Advanced & Expert Users

How to remove duplicate lines of a record without changing the order

Hi all, I have to remove duplicate lines in a file without chainging the order.for eg if i have a record pqr def abc lmn pqr abc mkh hgf the output should be pqr def abc lmn mkh hgf (7 Replies)
Discussion started by: abhi.roy03
7 Replies

10. UNIX for Dummies Questions & Answers

Changing the order using sed

I have a text "abc def ghi" and I want to get it as "def abc ghi" I am using this echo "abc def ghi" | sed 's/\(*\)\(*\)/\2\1/' But I am not able to get the output, could anyone help me. Thanks (9 Replies)
Discussion started by: venu_nbk
9 Replies
Login or Register to Ask a Question