[Q] cutting from one column and pasting to another


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Q] cutting from one column and pasting to another
# 8  
Old 10-31-2011
Quote:
Originally Posted by dude2cool
@Shell_Life, Your original code above was not working, I just modified it to above.
dude2cool:
Please, run my code exactly as I wrote:
Code:
sed 's/\(^....\)\(.\)\(.*\)/\2 \1\2\3/' Inp_File

# 9  
Old 10-31-2011
Quote:
Originally Posted by dude2cool
Here you go,

#
Code:
sed 's/\(...\)\(..\)\(.*\)/\2\1\2\3/' <path to your file>

Output from above:

4219 432 4567 Harrison Joel M 4540 Accountant 09-12-1985
4219 432 4587 Mitchell Barbera C 4541 Admin Asst 12-14-1995

@Shell_Life, Your original code above was not working, I just modified it to above.
True enough, that does work but doesn't follow the hint that follows the question "(Hint:Two good solutions exist, one in which you use a semicolon and one with more finesse in which you use a pipe character)"
Also, we haven't covered anything that looks like that line. That would be to advanced of a solution considering how little we've actually covered thus far.

I know I'm pushing it... curiosity did kill the cat. Sorry.
# 10  
Old 10-31-2011
How does this look to you:

#
Code:
cut -c5 file|paste -d " " - file|sed 's/ //'

or

#
Code:
cut -c5 file|paste -d " " - file|awk '{print $1$2,$3,$4,$5,$6,$7,$8,$9}'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cutting a column and pasting its number

Hello Gurus, This is my first ever post here. I tried looking for similar material but came up empty handed. Apologies if this is too verbose or if I'm not using the correct formatting. I have files containing a fixed number of elements per line; separator is a single space. Each line has the... (4 Replies)
Discussion started by: stdroid
4 Replies

2. UNIX for Dummies Questions & Answers

Cutting only the 1st column data

Hi All, I having a data file which consists of 20cr records in it. The 1st column is year field which consist of year in format 200809 and fields are seperated with ^. How do i trim it to 2008 in file and save it in a quick time as there are many records so that i can use the file for loading... (3 Replies)
Discussion started by: abhi_123
3 Replies

3. Shell Programming and Scripting

pasting problem

Hi Friends, Please help. I have 2 pipe delimited files; each one has different number of rows in it. I want to use "paste" to concatenate these files. However, while doing it, due to difference in number of rows in each files resulting file is in haphazard manner. E.g. file 1 Reliance Info|... (1 Reply)
Discussion started by: anushree.a
1 Replies

4. Shell Programming and Scripting

help with pasting files in filesystem

quick question.. say i have few files in D or E drive.. i want to paste them in Filesystem that is /home/vivek folder... but when i try to do that it shows some error saying "There is not enough space on the destination. Try to remove files to make space." but i think its due to authorization... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. UNIX for Dummies Questions & Answers

Pasting a column into a text file

I have two text files: One is a single column of numbers and the other is a space delimited text file with multiple columns. I want to paste the single column of numbers into the second column of the latter text file. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

Any shell scripts for cutting and pasting part of data?

Hi, I have a tab-delimited txt file as below. It is part of the original file. I want to cut the lines starting with "3" in column1 and paste them before the lines starting with "1" in column 1. So I will get Anyone knows any simple shell scripts to do that? The original file is... (5 Replies)
Discussion started by: cliffyiu
5 Replies

7. UNIX for Advanced & Expert Users

Bash shell: Cutting pasting only parts of the name of a directory into a variable

I have a script in a directory and want to search the directory before like follows: i=0 for file in ../HN_* do echo $file ((i+=1)) echo $i done Currently I get following output: ../HN_2 1 ../HN_3 2 (2 Replies)
Discussion started by: ABE2202
2 Replies

8. Shell Programming and Scripting

How to cut first line only from a text near a specific column without cutting a word

First I have to say thank you to this community and this forum. You helped me very much builing several useful scripts. Now, I can't get a solution the following problem, I'm stuck somehow. Maybe someone has an idea. In short, I dump a site via lynx and pipe the output in a file. I need to... (7 Replies)
Discussion started by: lowmaster
7 Replies

9. UNIX for Dummies Questions & Answers

Cutting the first 8 chars of a 2nd column

I am having a stupid moment :-) I have a tab-delimited file with 2 columns. I want to keep the first column as it is, but I only want the first 8 characters of the 2nd column. Example of input file data: --------------------------------- CATERPILLARS CW001651K.dwg... (9 Replies)
Discussion started by: cassj
9 Replies

10. Shell Programming and Scripting

Need help recurrently cutting single column file

Hi there ! I have file with single column. I want to cut that column at fixed number of rows each time and paste in another file, in a way that in new file, the each cutting appear as separate columns. I mean cutting file with one column of 10000 rows, with 100 rows each time, and in new file... (3 Replies)
Discussion started by: jacks
3 Replies
Login or Register to Ask a Question