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
0
votes
6answers
118 views

Delete columns that contains only numbers

I have a table that containes some data and I need to delete the columns that contains only number (Nr.,Cod,Tiraj): Nr. Autor Titlu Cod Tiraj Tara 1 Gauss Carl ...
1
vote
1answer
34 views

Get the Absolute Path from feh

The feh command allows you to view images within a folder recursively: feh --recursive --auto-zoom While viewing images, it also allows you to associate custom commands with keys 0-9 on your keyboard....
-1
votes
3answers
40 views

How to use cut to get the last field of /proc/pid/maps?

I need to do some processing on the list of .so loaded by a process. I tried cut with space as a delimiter but I didn't succeed. How to correctly pipe the output of cat /proc/PID/maps into cut to get ...
1
vote
1answer
77 views

Shell process substring

I know I can replace a substring with sed and integrate command evaluation with $(...). But what if I want the replacement to be calculated from the string to be replaced? Example I have a formatted ...
-1
votes
3answers
63 views

I have a fix length file how to extract the data to looks like csv file

So I have the following file: HDR2013100120131001000000000000 ...
2
votes
4answers
74 views

Linux sort and cut multiple columns

I have the following file named "info": White:73:Mars:1543:Manuel Green:17:Jupiter:1968:Sebastian Blue:24:Venus:1970:Anna Red:35:Neptune:1122:Javier Yellow:135:Earth:1234:Raymond I need to ...
0
votes
3answers
44 views

How to add texts between fields in cut command's output?

uptime | cut -d " " -f 4,5,6,7 | cut -d "," -f 1,2 The output of this command is 1 day, 20:07. And I want to add "Uptime: " before "1 day". (I want cut to ...
0
votes
2answers
105 views

How do I extract different fields of a filename in bash?

I have some log files to fuse. The filenames are of format environment.type-YYYY-MM-DD.log where: environment represents the server's environment: "private", "public", "para&...
1
vote
1answer
73 views

How to only display the text after the third, first, and fifth comma in this order in Unix?

I want to display the text after the 3rd, 1st, and 5th comma from a given input text, in that order. Doing cut -d ',' -f 3,1,5 does the job but doesn't keep the order I want. Instead, it displays the ...
0
votes
0answers
20 views

Tail and watch, filter and extract string [duplicate]

Lets says I have a file called test.log more rows being added all the time: one|two|apple|four|foo1 one|two|pear|four|foo2 one|two|apple|four|foo3 one|two|peach|four|foo4 I want to tail it but am ...
-1
votes
1answer
41 views

ls -l | cut -c1-11,50- Can Someone Explain the 2nd part after the pipe?

I have taken a course in that suddenly I saw this, I understood until the pipe but the options used after the pipe for the command cut are bit confusing
0
votes
3answers
51 views

extract certain substring

I have a file like this: RSID1 RSID2 chr1_169894240_G_T_b38 chr1_169894240_G_T_b38 chr1_169894240_G_T_b38 chr1_169891332_G_A_b38 chr1_169891332_G_A_b38 chr1_169891332_G_A_b38 chr1_169661963_G_A_b38 ...
0
votes
1answer
28 views

How do I parse information from a command after a particular word

I get information from the gpstate -s command and it prints with debug info that I would like to remove. There is one line in particular that I would like to save, the Master Host line. I need the ...
0
votes
2answers
59 views

Unix command to cut between strings

my file: Informatica(r) PMCMD, version [10.2.0 HotFix2], build [1911.0401], Workflow run status: [Failed] Output I need is Failed Output I am getting is 10.2.0 HotFix2 Command used: grep "...
0
votes
4answers
1k views

Grep and Cut command in linux

I have a csv file with loads of data. I wish to cut the 9th column for values >=1 and then use grep to display full rows that match. Sample format: ABC,XYZ,RTY,CREAM,FRANCE,170019,ST REMY CREME,...
0
votes
2answers
79 views

String Extraction

I have a file with the text pattern: AAAA - BBBB (CCCC) - (DDDD) I'm only interested in using the first set AAAA - BBBB individually (i.e. AAAA and BBBB) I've chopped off the '(CCCC) - (DDDD)' using: ...
1
vote
3answers
215 views

Bash awk/sed extract multiple strings from a single large string using keywords

Please help me figure out how to extract multiple substrings based on keywords. I have been struggling with different methods using delimiters My Input: Inventory for 30844-ap01 NAME: AP1800 , DESCR: ...
2
votes
2answers
49 views

How to remove four random characters before the .extension from various files using a for loop?

I am working on an undergraduate research project that is heavy in bioinformatics, and I am going down a pipeline of file processing. Some background: I am working with shotgun metagenomic data which ...
0
votes
1answer
37 views

print the next word after a match

I am trying the following in a bash script on Linux: envA="prdk8s--staging-a" envB="prd-k8s--sandbox" for envCode in $envA $envB; do Code=$(echo $envCode | cut -d "--"...
-1
votes
3answers
51 views

Can anyone get the default ip using only netstat -rn, while, read, and cut command?

As you can imagine, I should only use these commands to get the default IP of my virtual machine. netstat -rn gives the following output Kernel IP routing table Destination Gateway Genmask ......
3
votes
4answers
386 views

Using cut with pling/exclamation mark as a delimiter

In shell (not Bash) I have a string like this that I want to parse: stringhere/morestring!99 After parsing, I want to keep the 99 at the end, and throw away the rest of the string. The substring that ...
1
vote
2answers
36 views

How to get a specific set of characters from a string using cut (or not)

I am trying to extract the PHP version from this command: php -v php -v PHP 7.3.27-9+ubuntu20.04.1+deb.sury.org+1 (cli) (built: Feb 23 2021 15:10:30) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend ...
0
votes
2answers
33 views

Removing strings after first space only in first column

The following file is tab-separated. I tried to remove from the first column NbLab330C00 64506568 the number after space in order to get NbLab330C00. $ head LAB330_TE_annotation.gff3 ##gff-version 3 ...
-2
votes
1answer
34 views

Format data into excel [closed]

I have a large number of data in below format as a txt file. As you can see, each line has Title and then path. What is need here is, i need the data to be present next to each other in an excel - ...
0
votes
0answers
36 views

How to generate list of groups that own files in /tmp or other file system folders?

I'm using ls -l /tmp to list the files and their permissions in tmp folder. However, how do I list of groups that own files in the in /tmp folder or perhaps in other folder in file system? I'm hoping ...
1
vote
1answer
232 views

Word splitting when using cut if delimiter are multiple spaces

I am running a bash script doing following: cut -d ' ' -f2 <<< "aaa bbb" Getting as a result: bbb In case there is more than one space as delimiter (let's say three): cut -d ' ' -...
1
vote
2answers
58 views

Why isn't whitespace recognised by the unix core utils in my script?

I'm writing a short script to pull the price of bitcoin. The information will be piped into an i3block so that I can see the hourly price on my status bar - here is what I have so far. #!/bin/bash ...
2
votes
2answers
65 views

Replace strings between pair of characters

There's a file named sites.txt and it contains dynamic sites with long URLs like this: http://onesite.com/a.php?one=1&two=2&three=3 http://anothersite.com/b.php?one=1&two=2 http://...
-1
votes
2answers
196 views

Extracting data from a HTML table

Objective: 1) Return a name value from an <a> and 2) assess a cell value from a number of HTML table rows, conditionally returning 0 or 1 I do curl -s http://[server-fqdn]/stats/servers?t=db | ...
1
vote
5answers
175 views

Bash, cut off IP from string separated by dots

I've multiple results in the format 10.3.2.1.in-addr.arpa name hostname I want to remove the middle part ".in-addr.arpa" and reverse the IP address to, for example, 1.2.3.10. Is that ...
0
votes
1answer
131 views

How to to create a new file with specific columns from files in multiple folders in linux?

I have .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. For example: Data |___ SOB33D |___ ...
5
votes
5answers
542 views

Convert "10.1.1.1-10.1.1.3" format to "10.1.1.1-3"

I know this is possible, probably by using awk, but I can't think the solution for now. How do I convert IP format from 10.1.1.1-10.1.1.3 10.100.100.11-10.100.100.31 to 10.1.1.1-3 10.100.100.11-31 ...
0
votes
1answer
57 views

Selecting parts of a readable file using cut or awk

I have a file created with person names and a bunch of other things like phone numbers and addresses. I was wondering how could I select just the names of all the persons on that list. Please note ...
0
votes
1answer
41 views

How to split single rows of a CSV file into multiple depending on delimiter in 2nd column

My base.csv file has several entries a sample of which is below. NAME,IP_ADDRESS,PRI_IP,APP_CODE,APP_NAME,OWNER test2,10.9.7.12/10.222.101.11,10.9.9.12,545,myapp1,owner1 mytest,10.9.7.12,10.9.9.12,545,...
0
votes
0answers
79 views

How to print multiple characters [duplicate]

I want to print Multiple characters from a txt file. Example: I have a test.txt , inside a long string HELLOWORD HELLOWORD HELLOWORD HELLOWORD HELLOWORD HELLOWORD HELLOWORD HELLOWORD HELLOWORD ...
-2
votes
1answer
35 views

Unifiyng lines with awk

I have the file/text bellow: apple 1 apple 2 apple 3 banana 22 banana 5 string 1 How can I run a command to return the following result? apple numbers:1,2,3 banana numbers:22,5 string numbers:1
0
votes
1answer
61 views

Unexpected output of cut command

I am trying to convert the key value pair output of the script to csv file using the following commands. cat config/password | ssh -tt -J support@$gateway support@$ip "$(<${base}/systemkv.sh)&...
3
votes
2answers
797 views

Why does cut -d ' ' not work with space in this case?

I've no issue with this cut command. wolf@linux:~$ echo ab cd ef ab cd ef wolf@linux:~$ echo ab cd ef | cut -d ' ' -f 1 ab wolf@linux:~$ echo ab cd ef | cut -d ' ' -f 2 cd However, when I try the ...
5
votes
7answers
849 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
46 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
172 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
168 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
55 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 ...
-2
votes
1answer
46 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
65 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,...
1
vote
1answer
48 views

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

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
153 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 ...
2
votes
1answer
2k 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 ...
0
votes
1answer
305 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
924 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 ...

1
2 3 4 5
8