Problem in cut or paste


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in cut or paste
# 1  
Old 09-12-2013
Problem in cut or paste

Hello,

I have some problem in cut or paste command for my text data.

Input1.txt :
Quote:
Sam11 0 0 1 AB
Sam12 0 0 2 AB
Sam13 0 0 2 AA
I use cut command :
Code:
 cut -d ' ' -f1 Input1.txt > result.txt

result.txt :
Quote:
Sam11
Sam12
Sam13
Then, I use paste command to merge result.txt.
Code:
 paste -d ' ' result.txt Input1.txt > output.txt

output.txt showed :
Quote:
Sam11 Sam11 0 0 1 AB
Sam12 Sam12 0 0 2 AB
Sam13 Sam13 0 0 2 AA
I use cut command again to get data that I want :
Code:
 cut -d ' ' -f1,2,5 output.txt > Final.txt

Final.txt showed :
Quote:
Sam11 Sam11 1
Sam12 Sam12 2
Sam13 Sam13 2
However, Final.txt have something like question mark symbol (???) after Sam number which I can not see this symbol but some program can detect. I do not know what's happen because I use dos2unix in my dataset.

Could you please suggest me?
Thank you in advance.
# 2  
Old 09-12-2013
You can use awk command to get the desired output.. regarding ??? not sure what inbtw process happening in your script..

Code:
 
awk '{print $1" "$1" "$4}'  Input1.txt

This User Gave Thanks to vidyadhar85 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in Cut and paste

Hi, I have a file like this --> Consider z as space #cat filename ABC <!--Nzzzzz--> <!--RESUMO--> EFG XYZ <!--Nzzzzz--> <!--RESUMO--> I need to cut the <!--RESUMO--> part and paste it to the previous line so that the file will look like this--> ABC <!--Nzzzzz--><!--RESUMO-->... (4 Replies)
Discussion started by: samsonata
4 Replies

2. Shell Programming and Scripting

need help with cut and paste command

I have a file which contains 3 fields separated by tabs example andrew kid baker I need to swap kid and baker using cut and paste commands how is this to be done? Thanks (3 Replies)
Discussion started by: drew211
3 Replies

3. UNIX for Dummies Questions & Answers

Cut paste from one file to other

Hello, I am working on unix for the first time. I have to write a shell script where i want to cut paste from one file to other. File "1234.abc" is 03,12345555 16,936,x,x,120 16,936,x,x,100 49,12345555 03,12347710 16,936,x,x,115 16,936,x,x,122 49,12347710 03,12342222... (9 Replies)
Discussion started by: swapsb
9 Replies

4. Shell Programming and Scripting

cut and paste

Hi, Need a help with shell script. I have to search for a string in one of the file, if match found, copy the line to a new file and delete the line from the exisiting file. eg: 83510000000000063800000.1800000.1600000.1600000.2400000.1800000.2000000.21... (6 Replies)
Discussion started by: gpaulose
6 Replies

5. Shell Programming and Scripting

cut and paste?

hi, I have a file with content like this for an employee: EmployeeID 101 Day_type, day vacation,1/2/2009 sick day, 3/2/2009 personal day, 4/5/2009 jury duty day, 5/5/2009 how do I make the result to show: EmployeeID,Day_type,day 101,vacation,1/2/2009 101,sick day,... (6 Replies)
Discussion started by: jbchen
6 Replies

6. UNIX for Dummies Questions & Answers

cut and paste from two tables

Hello, I want to be able to cut and paste columns from two tables in one command. Presently I do the following: cut -f 1,3-6,9 table1.in > table1.out cut -f 7,6,1-3 table2.in > table2.out paste table1.out -d '\t' table2.out > MergedTable.out Is there a better way to do this? ... (1 Reply)
Discussion started by: Gussifinknottle
1 Replies

7. Shell Programming and Scripting

cut and paste using awk

Hi i need a favour i have a file which has some trillions of records. The file is like this 11111000000000192831840914000000000000000000000000000 45789899090000000000000000011111111111111111111111111 I want to cut specific postions in each line like cut1-3 and assisgn it to a variable and... (5 Replies)
Discussion started by: richa2.m
5 Replies

8. UNIX for Dummies Questions & Answers

cut, copy + paste

Hi all! How do I cut, copy and paste under unix??? (2 Replies)
Discussion started by: aitor314
2 Replies

9. Shell Programming and Scripting

Cut Paste and Insert Help

Hello I have a very large file where say each line is made up of 80 characters. I want to cut the characters from 20-30 and 50-60 from each line and then insert a delimiter between them (# or | etc). eg input file 000000000131.12.20990000590425246363375670011200140406... (5 Replies)
Discussion started by: PradeepRed
5 Replies

10. Shell Programming and Scripting

cut & paste

hi i am new to shell scripting, i have been trying to cut columns numbered 1,4 of a file consisiting of 4 columns. Each column is seperated by 2 spaces. for example: john 6102097199 tennessee usa michel 6734590899 texas USA now, i need to cut the name... (3 Replies)
Discussion started by: t_harsha18
3 Replies
Login or Register to Ask a Question