Skip to main content

All Questions

1 vote
2 answers
332 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 ...
Yosu Cadilla's user avatar
-2 votes
3 answers
1k 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 ...
Aleks Ignjatovic's user avatar
-1 votes
3 answers
2k views

Swapping the contents of two columns

I am trying to understand cut better and moving cut data to another file. I have a file called numbers with two columns. Each column is separated with one tab. I am trying to swap the columns by ...
R00ki3 M1stak3's user avatar
0 votes
2 answers
217 views

Remove string using certain values (-)

I have following text foo-11.11-fo.o-foo-bar bar-foo-11.11-22.11 I want to remove last strings that have two "-". Expected output: foo-11.11-fo.o bar-foo I have tried multiple methods ...
Buvanesh Kumar's user avatar
0 votes
3 answers
2k views

awk command to delimit the second column

I have a file with data in the below format Item1|keys,books,helmet,handle, Item2|Bike, Item3 Item4|Tyre,brakes,headlight,clamps,rollergrip, Item5|Nails,hammers, I wanted the above data to be ...
ramp's user avatar
  • 761
1 vote
2 answers
1k views

extracting domain names(hostnames) out of a text file

i wanted to extract domain name(hostname) with Connection timed out with top 5 delay time . input file Mar 19 21:44:00 ip-172-2-0-53 sendmail[30686]: v2K4g0Dm030684: to=<[email protected]>, ...
Mahesh Phate's user avatar
3 votes
2 answers
875 views

How to merge two files based on the matching of two columns? CSV

I have file1 likes: 6688249-7,03/02/2017,5515,02-feb-17 16914917-8,03/02/2017,5521,02-feb-17 And a file2: 5515,6688249-7,06-02-2017 04:25:47 PM,ASIG,ELIZABETH PRIETO 5515,6688249-7,06-02-2017 04:56:...
Daniel Zigma's user avatar
4 votes
3 answers
4k views

Find and replace hostname to ip address within a file

I have a huge file with about 12300 lines that look something similar to this. 001.domain.com=001.somedomain.com:10001 002.domain.com=002.somedomain.com:10002 003.domain.com=003.somedomain.com:10003 ...
Vituvo's user avatar
  • 411
4 votes
1 answer
2k views

I want to run cut command to extract some column from a large file and paste it to other file:

I want to extract some columns from a file and paste to another file. I am currently using: cat $Input_file | cut -f$Var_ColumnNo1,$Var_ColumnNo2,$Var_ColumnNo1 -d"," > $OUTPUT_file but this ...
NITIN RANJAN's user avatar
5 votes
4 answers
1k views

Excluding enclosed delimiters with cut

Let's say I have a CSV file: "col1","col2","col3" "col4","col5,subtext","col6 The problem I have is as follows : cut -d, -f1,2 test.txt "coll1","col2" "col4","col5 The desired output is : "col1","...
Little Code's user avatar
1 vote
1 answer
599 views

Cut Reorder and Output to Text

I'm currently learning CentOS and need some assistance if possible. I have a file UserNameList.lst, which is used to generate user accounts. The content of the file is below Josh, Adams, Joshadams@...
Leon's user avatar
  • 15
2 votes
7 answers
996 views

string manipulation without awk or sed

any help on this problem is appreciated I have a text file with the following format We can safely assume that the names are always three characters long, profession 7 characters and salary 5 ...
user3363135's user avatar
0 votes
1 answer
417 views

How to extract particular fields from lines using shell commands?

File1: 27/07/2014 10.10.03 Breaker1 was closed by Mr. A.Basu Spectrum ui6dms 29/07/2014 04.50.53 Breaker1 was opened by Mr. D.Gupta Spectrum ui6dms and one note added 30/08/2014 03.20.01 EarthSwitch ...
Nainita's user avatar
  • 2,962
1 vote
2 answers
1k views

Extract and format data with `cut` and `awk`

I have the below file in txt: "Firstname","Lastname","Company" "Alex","Johnson","Alex Corp." "Baran","Atasoy","Gülerler Ltd." I would like to extract and format data by using awk and/or cut and have ...
Kerim Güleç's user avatar
1 vote
2 answers
198 views

Split out data from a column

So at the moment I have some input email addresses and would like to separate the alias and the domain, then copy them to the end of the line. For example, from a line that has [email protected]:blah:...
Peter's user avatar
  • 151