Questions tagged [cut]

For questions pertaining to cut, a filter program which extracts fields or columns of each line of input. Use this tag for questions about cut itself or questions about issues arising from using the cut utility.

Filter by
Sorted by
Tagged with
5
votes
7answers
510 views

Parse a string using keywords

I am using a bash command, gps location, that returns a date, time and location information. [john@hostname :~/develp] $ gps location Location: {"date": "16/07/20", "time"...
1
vote
1answer
37 views

Update data using search & replaces

get_data.txt ald900 NON-Prod GOOG037-A US ald9024 NON-Prod GOOG037-A SRI-LANKA ald978 NON-Prod GOOG037-A JAPAN I have two given data. I need to search in get_data.txt ...
0
votes
6answers
99 views

Split each line by a delim read from another file and store all split word compounds in the result file

I want to split each line from file names by each and every delimiter from file delim and store the unique word compounds into result file compounds. Lines from names that were not split should be ...
0
votes
0answers
21 views

Cut specific lines of file? [duplicate]

I have a 100 line text file. I want to extract lines 50 to 70 inclusive. How can I do this? My Google skills are failing me and man cut doesn't seem to have the answer - perhaps I need a different ...
1
vote
0answers
36 views

How to export multiple user to a file

#!/bin/bash id=`id -u` if [ $id -eq 0 ] then echo "eres root puedes continuar" else echo "no eres root" echo "para continuar loqueate como root" fi for i in `cat secretaria.txt` do ...
0
votes
0answers
25 views

Limit output in bash to be certain number of characters not including invisible characters [duplicate]

git log --oneline | cut -c-20 outputs git log and limits the output of lines to 20 characters each. But with git log --oneline --color | cut -c-20 the output is only 10 characters per line, because ...
-1
votes
2answers
43 views

Appending column with same key within a file

I need some formatting for my file to append the columns of then line to another with same specific column. The column that need to match are 1st column(numbers) and Type (Sword_SC, Fire_ball_sc, ...
0
votes
1answer
60 views

How would I go about adding new data to a file?

So! I have an nmap scan that saves the output to a file, nmapscan.txt: sudo nmap -sP 192.168.1* > nmapscan.txt I also have a few other commands to clean up and save all desired output to one file,...
0
votes
0answers
31 views

How do I cut text from one file and replace it with text in another file?

So I have a text file, mac.txt, with one line that looks like this: 4a:38:61:e1:71:7c And I have a bash script, mask.sh, that simply changes my mac address: #!/bin/bash sudo ifconfig wlan0 down ...
0
votes
3answers
66 views

How to use awk to extract the required columns and create a new file?

I have gtf files in more than 100 directories. Below I'm showing how they look. SampleA |___________ SampleA.GRCh38.gtf SampleB |___________ SampleB.GRCh38.gtf Here I'm showing only two gtf ...
1
vote
1answer
180 views

split line using delimiter and store both fields in a different variable

I have a text file having multiple rows. I am using the while command to read the file line-wise but I need to store the values in separate variables and use them in the trailing shell-script. The ...
-1
votes
1answer
32 views

How to use cut to create a single file with required columns from multiple files in linux

I have estimate.tsv files in more than 100 directories. I want make a single file with all the information needed from all those tsv files in the 100 directories. The data in estimate.tsv file looks ...
0
votes
1answer
65 views

cut -d not working?

I'm trying to extract all the lines from a file that end with /42 and then remove said /42 with the command cut but for some reason its not working. Here is the command grep "42$" questionnaires.txt &...
0
votes
3answers
188 views

Cut the spaces and hyphen from a text file

The text file I have now looks like this, VOG0005 - k141_44786_1 - 4.9e-11 41.0 0.0 2e-08 32.4 0.0 2.0 2 0 0 2 2 2 2 - VOG0005 ...
2
votes
3answers
136 views

how to align hypen

This is my command echo -e "Test sur la vie, l'univers et le reste \n " >test42 |grep '42' questions.txt | nl -w1 -s ' - ' | cut -d "/" -f 1 >> test42 this is the output Test sur la vie,...
0
votes
2answers
50 views

Perform series of commands on every value in a field

I have a tsv file. For a specific value in a column 5, I want to extract all the rows, and then cut three columns and then count the unique lines. For example for string 'abc' in column 5, I want awk ...
0
votes
1answer
29 views

Duplicate columns of a bed file to produce another bed file

I have a bed file genome_cov.bed specifying the coverage of a genome at every position on the genome. The columns are; scaffold, position, coverage. scaffold_1 1 0 scaffold_1 2 ...
0
votes
1answer
26 views

How to replace a positioned value in a file in Linux /Solaris

I have the file containing lines which are pipe separated like below. 45|abc|NULL|hol| Gha|ghsk|NULL|gah| How can I replace 3rd column values (Null) with something like a hyphen(-). The value in ...
-2
votes
4answers
914 views

How I remove last word from my every line with AWK or CUT

ACRBAMIDKC124,/Program Files (x86)/BigFix Enterprise/BES Client/__GTS/jre/bin/java.exe ACRBAMIDKC124,/Program Files/Java/jre6/bin/java.exe ACRBAMIDKC125,/Program Files/Tivoli/TSM/baclient/jvm80535/jre/...
0
votes
3answers
86 views

cut but keep last delimiter?

I have echo "/home/user/test/folder" | cut -d'/' -f4- give: test/folder But I want to keep the last delimiter, expected result would be: /test/folder how to achieve with cut?
10
votes
3answers
795 views

cut command seems not to work in a pipe

I am able to filter out jobs which got stuck in our queueing system with: > qjobs | grep "racon" 5240703 racon-3/utg001564l-racon-3.fasta H 1 1 0 10.0 0.0 150 :03 ...
0
votes
1answer
78 views

sort in pipe does not work

I have many of those files and I would like to know what is the highest Memory consumption (Mem) $ cat utg006012l-racon-2.fasta.o5230935 [racon::Polisher::initialize] loaded target sequences 0.013133 ...
0
votes
2answers
81 views

How to filter only particular lines from a file?

I have a file which has following lines. I just was to see IP address which is the first line, second line country only once and the score line only once but the score line should be the highest value ...
0
votes
1answer
81 views

How to output specific columns separated by a special delimiter using cut

I have a file which contains several columns separated by special delimiter with multiple chracters like this: <xx>. A line will look like this: firststring<xx>11<xx>thirdstring/&...
0
votes
3answers
53 views

Can I combine cut commands and use custom delimiters

I have log file where I need to extract URLs from GET requests which have 404d I have used : grep 404 testfile.txt | cut -f 2 -d '"' | cut -f 2 -d '/' | cut -f 1 -d ' ' | sort -u Is is ...
0
votes
1answer
3k views

Understanding the output of cut -f [duplicate]

Thank you for your patience I am new to linux and I wanted some help understanding how I can parse the output of the cut command. So, currently I have a variable x=$(discover nginx --human=nood | ...
0
votes
2answers
149 views

Cut works with echo but not without it

So I am trying to extract an output similar to x=($discover nginx --human=nood) which gives me an output like i-03099 nginx IP noodlefish pip b4b966d280546c6b070f5f952c281d3294308048 ...
2
votes
2answers
155 views

cut now has a line length limitation?

I had a script, with a 25,000 character input that I was using 'cut' on: ...\n" | cut -c -$LENGTH I didn't use it that frequently, but it was working (oh, about a year or two ago). Granted, my ...
11
votes
7answers
2k views

How to remove empty lines from begin and end of file?

I would like to remove empty lines from begin and the end of file, but not remove empty lines between lines. I think sed or awk would be the solution. Source: 1: 2: 3:line1 4: 5:line2 6: 7: 8: ...
-2
votes
3answers
158 views

How to cut a line at a specific character

I have a bunch of lines in a file that look like this word_word_word 0 word_word word_word_word 1 wordwordword word word word word 0 word word word word word 2 word_word_word word word word word_word ...
0
votes
2answers
274 views

Print last N characters from all lines in a file using cut

I have following content in a file foobar bar bar foo foo bar bar foobar I would like to get get the last character from all the lines, also last 3 characters. I am using following for loop ...
0
votes
1answer
41 views

What is a sensible way to pipe the first argument and all proceeding arguments separately

Problem I have a command which I alias as a convenience where I annoyingly need to use -- to specify some additional parameters after the call to the command. Take the example below, the command is ...
1
vote
1answer
17 views

How to display all sub string found in cut command

I've a grep command grep -o 'ITEM+[^ ]*' "file.txt" And the returned string is like this ITEM+12345678::hashtext_20191030::ITEM+87654321::hashmap_20191030::ITEM+12348765::hashvalue_20191001 So ...
1
vote
5answers
802 views

how to remove the row spaces using cut command

from this: 1 2 3 4 5 6 The result should be like this: 1 2 3 4 5 6
10
votes
4answers
1k views

How to create numeronyms in bash

I am trying to write a code that would turn any given word to its numeronym. for example : internationalization = i18n (first char+number of chars in between+last char) I found how to find the first ...
0
votes
1answer
75 views

If I save file to my hdd (not ssd), move 2 trash, then cut /paste from trash to usb, will this hold up to forensic analysis designed to recover files?

If I save a file (.odt,.txt, jpeg, etc) to my hdd (not ssd), move to trash, then cut /paste the files in the trash to a usb, would this hold up to the best forensic equipment trying to recover the ...
0
votes
1answer
23 views

Remove specific field if the column matches on the other column

I have a file contains duplicate fields. Sample file: ID |Date|id |date|name|...(up to 71 fields) 1313335|xxx |1313335|xx |Zuan| 1677783|xxx |1677783|xx |Zen| 11106A7|xxx |Zack | If ...
0
votes
1answer
46 views

How to cut specific lines from tab separated columns?

I have a file (.gff3) that has nine columns separated by tabs. ##gff-version 3 ##other information 0 . mRNA 1300 9000 . + . ID=mrna0001;Name=sonichedgehog 1 . exon 1300 ...
0
votes
0answers
63 views

Prevent xargs from appending a dot at the end of the term

I am trying to use the gdrive command line app via a script. The output of gdrive is whitespace delimited, and I need to process further the first term (which is a filename) of the output with a ...
-1
votes
5answers
71 views

get 2 texts from this line

Get 2 texts from this line: [23/08/2019 09:30:00 351] [DEBUG] [Hilo:Thread-17905] [Clase:co.com.colombiamovil.activator.db.PoolFacade: getSiebelDirectConnection (81)] [Conexi???n establecida 7682 ...
-2
votes
1answer
50 views

Need to fetch only the required part [closed]

We have a string as below: **XX_EMAIL_FILES FCP_REQID=9614696 FCP_LOGIN="APPS/sup12" FCP_USERID=5667 FCP_USERNAME="SRI" FCP_PRINTER="noprint" FCP_SAVE_OUT=Y FCP_NUM_COPIES=1 "...
0
votes
2answers
27 views

Aligning data to be imported in Database

I have file that contain 44 columns. The problem is the there's , on one field. I would like to divide that data on the particular column and put it on the next column of it. Raw: 122|abc |ds,we ...
2
votes
1answer
73 views

Find and Replace on a particular column

I like to find and replace on the specific column using sed, because I don't know why awk gsub() didn't work in my Unix (Solaris) that's why I want to use sed. Sample Data: 122|abc|ds,we||wrqg 145|...
1
vote
1answer
247 views

What is the use of n option in cut command?

I'm learning about the cut command. In the man page of cut, they show the -n option like: -n (ignored) But I didn't understand the usage of the n option or when we would use it. Can anyone ...
0
votes
1answer
158 views

Use first column as header for csv

I have an input file as follows hello: hello12 foo: bar14 test3: pppp more: stuff test14: bla Is there a way to use the first column as header and separate it by comma's as follows: hello,foo,test3,...
3
votes
2answers
68 views

Select columns from big file, using rows from another file

I want to select the columns from a big file ,based on the rows from another file. This problem has been answered here but both the solutions does not work. https://www.biostars.org/p/166527/ DATA....
0
votes
5answers
82 views

Putting a command inside awk to merge columns of different files

I have a file.txt for example (it does not have the same number of columns for each row): 1 2 3 4 5 5 6 7 7 7 7 9 10 I have another file (file2.txt) that contains 2 columns a b c d e f ...
0
votes
2answers
73 views

Search a string on the specific columns using GREP/AWK/CUT

Kindly modify my script, because I want to search the word "dBm" in Column 1,3, and 4 of File.csv and return all unmatched lines/records 'cause "dBm" need to be deleted on the file. cat File.csv | ...
2
votes
4answers
95 views

how to cut first 3 folders from this echo “/home/test/var/opt” ? i need the result “/home/test/var”

How to cut first 3 folders from a string? For example: echo "/home/source/Oracle/test" |cut -d'/' -f4 gives only one folder name, but I need up to the 3rd folder, like below: echo "/home/test/...
0
votes
1answer
52 views

Group items from column using awk

Trying to do the following, I have txt file which as the data of the interfaces. Eth1/15 desc01 1 Eth101/1/11 desc01 1 Eth101/1/16 desc01 1 Eth103/1/21 desc01 1 Eth1/2 ...

1
2 3 4 5
8