how to remove columns except the last one?

I want to move the columns except for the last, I do not know if there was any way to do it with awk or sed or some other line command

 ...
    00000000: 30327c30 30303131 36333132 567c317c  0|2011002136|1|V
    00000010: 44204149 56452045 4d415449 544e4549  IA DE EVITAMIENT
    00000020: 7c007c4f 30327c00 302d3131 37312d33  O|.|.|2011-03-17
    00000030: 3a393020 303a3035 33427c30 38313957   09:50:00|B3W918
    00000040: 327c317c 7c39397c 4f52544f 4f4d7c53  |1|2|99|OTROS|MO
    00000050: 414b4f54 7c007c52 7c007c00 36312d47  TOKAR|.|.|.|G-16
    00000060: 7c54527c 444e4f43 52494355 204e5520  |RT|CONDUCIR UN 
    00000070: 49484556 4f4c5543 524f5020 414e5520  VEHICULO POR UNA
    ...

i tried, but only delete the first column

$ cat file | sed -E $'s/ +/\t/g' | cut -f2-

i want this result. The last column

    ...
    0|2011002136|1|V
    IA DE EVITAMIENT
    O|.|.|2011-03-17
    09:50:00|B3W918
    |1|2|99|OTROS|MO
    TOKAR|.|.|.|G-16
    |RT|CONDUCIR UN 
    VEHICULO POR UNA
    ...

Seems like you're just trying to get last 16 chars.

$ sed 's/.*\(.\{16\}\)/\1/' file
0|2011002136|1|V
IA DE EVITAMIENT
O|.|.|2011-03-17
 09:50:00|B3W918
|1|2|99|OTROS|MO
TOKAR|.|.|.|G-16
|RT|CONDUCIR UN
VEHICULO POR UNA

I took a closer look at your sample and realized that it is a hex dump generated with xxd -e. If you want to obtain the original file, use following:

$ xxd -r file | xxd -e | xxd -r > original_file
$ cat original_file
0|2011002136|1|VIA DE EVITAMIENTO|||2011-03-17 09:50:00|B3W918|1|2|99|OTROS|MOTOKAR||||G-16|RT|CONDUCIR UN VEHICULO POR UNA

P.S: original_file contains NUL bytes but they're not shown on terminal.

Selecting/excluding sets of columns in pandas, You can either Drop the columns you do not need OR Select the ones you need # Using DataFrame.drop df.drop(df.columns[[1, 2]], axis=1, inplace=True) # drop � How to remove duplicate rows but keep the one with latest date in Excel? 1 . Select the data range that you want to remove duplicates and keep the most recent date from another column. 2. Then click Kutools > Merge & Split > Advanced Combine Rows , see screenshot: 3 . In the Combine Rows Based on

Pandas: Select all columns, except one given column in a , Pandas: Select all columns, except one given column in a DataFrame. Last update on February 26 2020 08:09:31 (UTC/GMT +8 hours)� Note: Different loc() and iloc() is iloc() exclude last column range element. Method #5: Drop Columns from a Dataframe by iterative way. Remove all columns between a specific column name to another columns name.

Just delete the first 5 space-separated fields.

With GNU sed:

$ sed -E 's/(\s+\S+){5}\s+//' file
0|2011002136|1|V
IA DE EVITAMIENT
O|.|.|2011-03-17
09:50:00|B3W918
|1|2|99|OTROS|MO
TOKAR|.|.|.|G-16
|RT|CONDUCIR UN
VEHICULO POR UNA

With any POSIX sed:

$ sed 's/\([[:space:]]*[^[:space:]]*\)\{5\}[[:space:]]*//' file
0|2011002136|1|V
IA DE EVITAMIENT
O|.|.|2011-03-17
09:50:00|B3W918
|1|2|99|OTROS|MO
TOKAR|.|.|.|G-16
|RT|CONDUCIR UN
VEHICULO POR UNA

How to drop one or multiple columns in Pandas Dataframe , Last Updated: 10-12-2018. Let's discuss Drop one or more than one columns from a DataFrame can be achieved in multiple ways. Create a� Pandas: Select all columns, except one given column in a DataFrame Last update on February 26 2020 08:09:31 (UTC/GMT +8 hours) Pandas: DataFrame Exercise-58 with Solution

awk '{print "    "$NF}' file
...
0|2011002136|1|V
EVITAMIENT
O|.|.|2011-03-17
09:50:00|B3W918
|1|2|99|OTROS|MO
TOKAR|.|.|.|G-16
UN
UNA
... 

Selecting/excluding sets of columns in pandas, You can select the columns that are required or drop them if it is not required. # Using DataFrame.drop. df.drop(df.columns[[1, 2]], axis=1,� awk to split one field and print the last two fields within the split part. Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields.

The simplest solutions don't seem to have been mentioned.

You really just want the characters beginning in the 52nd position. So use cut:

Input:

▶ cat > FILE <<EOF
    00000000: 30327c30 30303131 36333132 567c317c  0|2011002136|1|V
    00000010: 44204149 56452045 4d415449 544e4549  IA DE EVITAMIENT
    00000020: 7c007c4f 30327c00 302d3131 37312d33  O|.|.|2011-03-17
    00000030: 3a393020 303a3035 33427c30 38313957   09:50:00|B3W918
    00000040: 327c317c 7c39397c 4f52544f 4f4d7c53  |1|2|99|OTROS|MO
    00000050: 414b4f54 7c007c52 7c007c00 36312d47  TOKAR|.|.|.|G-16
    00000060: 7c54527c 444e4f43 52494355 204e5520  |RT|CONDUCIR UN
    00000070: 49484556 4f4c5543 524f5020 414e5520  VEHICULO POR UNA
EOF

Output:

▶ cut -c52- FILE
0|2011002136|1|V
IA DE EVITAMIENT
O|.|.|2011-03-17
 09:50:00|B3W918
|1|2|99|OTROS|MO
TOKAR|.|.|.|G-16
|RT|CONDUCIR UN
VEHICULO POR UNA

Note that cut can be emulated in sed this way, as noted in a comment:

▶ sed -E 's/.{51}//' FILE

Another way is to use AWK to set the field widths, if you have a version of AWK that supports it like GNU AWK, nawk (Mac OS X) etc.

▶ gawk 'BEGIN {FIELDWIDTHS = "15 9 9 9 9 16"} {print $6}' FILE
0|2011002136|1|V
IA DE EVITAMIENT
O|.|.|2011-03-17
 09:50:00|B3W918
|1|2|99|OTROS|MO
TOKAR|.|.|.|G-16
|RT|CONDUCIR UN
VEHICULO POR UNA

The benefit of the AWK solution is, while a little more effort to set up, it communicates more information about your expectations of the data to the reader of your code.

To figure out where all the columns begin, you can use CTRL + g in Vim after positioning the cursor on them.

Pandas Drop Duplicate Rows, subset: column label or sequence of labels to consider If 'last', duplicate rows except the last one is deleted. Can someone help me how to Print all columns except the first one Output file-----snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3 sns06.3.0 sw version 1.1 code MD5 192F MD12 sns06.3.0 sw version 1.1 code MD5 192F0\ MD8 sns06.3.0 sw code MD5 19 sn06.3.0 sw version 1.1 code MD5 19 ss06.3.0 sw version 1.1 code MD5 192F ss06.3.0 sw version 1.1 code

[100% Working Code], By nature .drop() does not perform inplace; Permenantly remove b from df do f. drop('b', inplace=True). The function df. 1. Open the worksheet you need to repeat rows on top except the last page, then press Alt+ F11keys simultaneously to open the Microsoft Visual Basic for Applicationswindow. 2. In the Microsoft Visual Basic for Applicationswindow, click Insert> Module.

R : Keep / Drop Columns from Data Frame, Later we are telling R to select all the variables except the column names specified in the vector drop. The function names() returns all the column names and� To delete columns by using Object Explorer In Object Explorer, connect to an instance of Database Engine. In Object Explorer, locate the table from which you want to delete columns, and expand to expose the column names. Right-click the column that you want to delete, and choose Delete.

Exclude a Column using SELECT *, Learn how to exclude a column in the SELECT statement of your query. Last modified: August 18, 2020. In some cases, you Not including columns or deleting columns you don't want in your SELECT statement is straightforward. Here is how it would look if we wanted to end up with all of the columns except column2:. In this example, we are going to remove table columns when the “Remove Column” button is clicked. So all code will go into the click event of the button. With that in mind, let’s take a look at how you can remove a single column and / or remove multiple columns from table using jQuery. The acutal code will be following by additional code

Comments
  • Do you want to keep the spaces in the front?
  • I don;t think there's any tool I love but as mentioned previously I do appreciate sed and use it almost every day. In this case I'm using sed because cut works on single char delimiters and idk if the spaces in the example are tabs or blanks and if they are blanks I'm not sure if the real data starts with the number of blanks in the question, etc. My gut instinct is that the spaces between the last 2 columns are tabs while the rest blanks but idk. With the sed solution I posted I know it'll work no matter what those spaces are and no matter how many of them there are,
  • Always add explanations to your answers to explain to the OP and others what you are solving