delete 7th column in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers delete 7th column in unix
# 1  
Old 12-16-2005
delete 7th column in unix

Hello.,

i have a file with 15 column. i want to remove the 7th column from the file.
i am trying to use awk to delete the 7th column.
can anyone help me how to do this

thanks
# 2  
Old 12-16-2005
Code:
nawk '{for(i=1;i<=NF;i++) line=(i==1)?$i:((i==7)?line:line OFS $i);print line}' pavan.txt

# 3  
Old 12-17-2005
deleting coloumn

Hi You can use this script you can minimise the command more.
but i thought to give more detailed eg:-

cat $FILE|while read LINE
do
filename=`echo $LINE|awk '{print $7}'`
echo "Deleting $filename"
rm -f $filename
done.
# 4  
Old 12-17-2005
Quote:
Originally Posted by sudhanshu_sinha
Hi You can use this script you can minimise the command more.
but i thought to give more detailed eg:-

cat $FILE|while read LINE
do
filename=`echo $LINE|awk '{print $7}'`
echo "Deleting $filename"
rm -f $filename
done.
How exactly does this relate to the OP's question?
# 5  
Old 12-19-2005
I am sorry about the last reply i misunderstood my mistake
# 6  
Old 12-19-2005
Computer

You can also use the 'cut' command to remove columns.
Code:
cat filename | cut -f1,2,3,4,5,6,8,9,10,11,12,13,14

# 7  
Old 12-20-2005
Avoid the UUOC by using...
Code:
cut -f1-6,8- filename

These 3 Users Gave Thanks to Ygor For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to compare 3rd column value with first column and display

Hello Team, My source data (INput) is like below EPIC1 router EPIC2 Targetdefinition Exp1 Expres rtr1 Router SQL SrcQual Exp1 Expres rtr1 Router EPIC1 Targetdefinition My output like SQL SrcQual Exp1 Expres Exp1 Expres rtr1 Router rtr1 Router EPIC1 Targetdefinition... (5 Replies)
Discussion started by: sekhar.lsb
5 Replies

2. Shell Programming and Scripting

Delete last characters in each column

I need to delete the last 11 characters from each number and they are all in the same line (each is in a different column): -6.89080901827020800000 3.49348891708562325136 1.47988367839905286876 -2.29707635413510400000 -3.49342364708562325136 -4.43758473239905286876 -2.29707635413510400000... (14 Replies)
Discussion started by: rogeriog.em
14 Replies

3. UNIX for Advanced & Expert Users

Copy a column to another column in UNIX fixedwidth file

Hi All, I have a fixedwidth file of length 3000. Now i want to copy a column of 4 chars i.e( length 1678-1681) to column 1127 – 1171 to the same file. Please let me know how can i achive using a single command in fixed width file. Also source column length is 4 chars and target column length... (4 Replies)
Discussion started by: kiranparsha
4 Replies

4. Shell Programming and Scripting

Delete Space between last and first column

HI Input A R04 tion=1 Li 51599 R08 tiea=1 Li 51995 R11 ocatea=1 Li 51992 R12 nArea=1 Li ... (2 Replies)
Discussion started by: asavaliya
2 Replies

5. Shell Programming and Scripting

delete the same column

var1 var2 var3 var4 var5 var6.... A G A T G T G A A A A A A A A A A A G A G T A T let's call this "file1.txt" we can see that var2 and var5 have the idential values. I would like to make a script so that if any variables (could be more than 2) have the identical values, i want to... (4 Replies)
Discussion started by: johnkim0806
4 Replies

6. Shell Programming and Scripting

for each different entry in column 1 extract maximum values from column 2 in unix/awk

Hello, I have 2 columns (1st column has multiple entries but the corresponding values in the column 2 may be the same or different.) however I want to extract unique values for each entry in column 1 by assigning the max value from column 2 SDF4 -0.211654 SDF4 0.978068 ... (1 Reply)
Discussion started by: Diya123
1 Replies

7. UNIX for Advanced & Expert Users

grep 7th column from a file seperated with ^

Hi, Can anyone help: I want to get the 7th column of a file seperated by ^ Num:^ 1^ testdevice1^10.1.1.1^PT1X23^true^HD^175^up^false^bad Num:^ 2^ testdevice2^10.1.1.2^ST1X23^true^SN^175^up^false^bad Expected result: HD SN Appreciate your help. (2 Replies)
Discussion started by: sureshcisco
2 Replies

8. Shell Programming and Scripting

delete first column

Dear All, I need to delete the first column, which blank in the tab delimited file and i need to print all the other columns with out disturbing the format of the file. I have tried with the followings and its not working for my case awk '{$1=""}1' file > newfilecut -d, -f2- dataCan anyone... (6 Replies)
Discussion started by: Fredrick
6 Replies

9. Shell Programming and Scripting

Delete first row last column

Hi All, I am having following file and I want to delete 1 row last column. Current File Content: ================ procedure test421 put_line procedure test321 test421 procedure test521 test321 procedure test621 test521 Expected File Content: =========================== procedure... (3 Replies)
Discussion started by: susau_79
3 Replies

10. UNIX for Dummies Questions & Answers

to delete a column in unix

Hai Please let me know the command in unix(command mode ) from a file that deletes the whole column (not 1st and last column )& replace with numbers starting from 1. Regards suneetha. (8 Replies)
Discussion started by: gaddesuneetha
8 Replies
Login or Register to Ask a Question