Questions tagged [cut-command]
The cut-command tag has no usage guidance.
32 questions
2
votes
0
answers
374
views
Add Terminal Cut (Ctrl+k) to GPaste clipboard
I don't know if this is a local bash setting on my part, but when I cut a line within a terminal (or gnu screen) using Ctrl+k, the result isn't copied to GPaste. Instead, the copied text can only be ...
2
votes
1
answer
3k
views
option delimiter in cut
I want to know if it is possible with the cut option to indicate the delimiter with a line break "\n" or "\t".
Ex: cut -f 1 -d "\t". This line gives me error.
0
votes
1
answer
753
views
Capture a string from JSON response
I have below Json response for POST method in bash and would like to capture value after sessionId":" and assign it to variable session_ID.
{"changeId":"79911476-53a4-46e1-...
1
vote
3
answers
714
views
How to delete part of a line and keep the rest using Bash?
Suppose that I have an output of lines like this:
First name, Last name, 123456789(9 digits)
GPA
Class
Major
University
How can I write some code to print the first 3 lines and only keep the ID ...
1
vote
1
answer
2k
views
cut command - How to find the end of line with N bytes
I want to cut a line from the 13th byte until the end of the line, but I don't know how many bytes there are in the line.
How can I find the end of the line?
I tried to do:
cut -b 13-CRFL $textfile
...
21
votes
2
answers
3k
views
Why is character "£" in a string interpreted strange in the command cut?
I'm developing a bash script and came up with the following strange behaviour!
$ echo £ |cut -c 1
�
The sign £ is passed to the next command cut whose filter is picking one character only.
When I ...
0
votes
0
answers
67
views
Using cut efficiently help
I have this command: cut -c 1,9,17,25,33,41,49 data > results
However this is not efficiently written.
Any shorter way to write something similar ?
Thanks
1
vote
1
answer
236
views
How to add n columns below first column? [closed]
I have a tab-separated data:
1-1 2-1 3-1 ...
1-2 2-2 3-2 ...
1-3 2-3 3-3 ...
1-4 3-4 ...
3-5
My desired output should look like this:
1-1
1-2
1-3
1-4
2-1
2-2
2-3
3-1
3-2
3-3
3-4
3-5
...
...
1
vote
1
answer
67
views
How to filter data with the highest number
I have thousands data like this:
abc_1
abc_2
abc_3
abc_4
def_1
def_2
def_3
ghi_1
ghi_2
I want to filter it to get only data with the highest number which is abc_4, def_3, ghi_2.
How I can get it?
2
votes
2
answers
1k
views
How to split string in TSV file
I have TSV file like this:
abc_1
def_2
ghi_3
jkl_4
mno_5
I want to split that in to the:
abc
def
ghi
jkl
mno
and
1
2
3
4
5
How I can get that?
3
votes
2
answers
454
views
How to insert filename by changing format to same file?
I have many files. File format is year(4-digit)month(2-digit)day(2-digit)
Sample filenames:
20150101.txt
20150102.txt
Content of sample filenames
00:00:13 -> 001528
I want to extract data as ...
9
votes
4
answers
6k
views
How would you separate fields with multiple spaces and store them in an array?
In my file mytxt:
field1 field2
------ -------
this are numbers 12345
this letters abc def ghi
Let's say I want to store the first field ...
10
votes
6
answers
7k
views
How to remove the first colon ':' from a timestamp?
I am new to programming!!
Can anyone help to remove the : at the first position in a timestamp: :29.06.2019 23:03:17
Presently I am trying to do it using awk/cut commands as shown below:
TDS="$(...
1
vote
2
answers
215
views
Can cut keep just the first letter after a comma and whitespace?
I have input that looks like this:
Austin, Ashley D
Bender, Isaiah J
Here I am trying to cut the first name till the "," and then add the first letter of second name.
For example, the above two ...
1
vote
1
answer
346
views
How can I make an alias for a long ls command?
When I type in xfce4-terminal the command:
ls -pltrh --color=always --time-style="+%d-%b-%Y $newline%H:%M" | grep --color=never -v / | cut -d ' ' -f6-
echo -e -n '\033[1;5;36m'"Diretório §⮕ "
echo -...
1
vote
1
answer
57
views
Correctly locate the desired field from cut operation
I have such processes running
me 26175 1.7 2.5 1483984 100148 tty2 Sl+ 12:49 0:04 /snap/electronic-wechat/7/dist/electronic-wechat-linux-x64/electronic-wechat
me 26237 0.0 0.7 311516 ...
2
votes
1
answer
244
views
cut not outputting anything
I created a script by using the command line initially:
grep -c "Author" reviews_folder/* | cut -d \/ -f 2 | sort -nt':' -k2 | sed 's/.dat:/ /g'
It worked, however I then needed to make it a shell ...
0
votes
1
answer
2k
views
Cut the second field delimited by spaces
I want to retrieve the second column from ps result:
test@pc:~$ ps -e | head -5 | cut -d '' -f1
PID TTY TIME CMD
1 ? 00:00:03 systemd
2 ? 00:00:00 kthreadd
3 ? ...
2
votes
3
answers
278
views
Remove certain fields from a line
I have the following lines in a file:
Modified folders: html/project1/old/dev/vendor/symfony/yaml/Tests/bla.yml
Modified folders: html/port5/.DS_Store
Modified folders: html/trap/dev8/.DS_Store
...
12
votes
1
answer
2k
views
`cut -d: -f5-` prints lines even if they have no colon
Assuming a file named "file" containing the lines:
foo:bar:baz:qux:quux
one:two:three:four:five:six:seven
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
the quick brown fox jumps ...
2
votes
0
answers
298
views
can't cut/Paste or move file in all my partition even using "sudo nautilus"
I have big problem to use my PC because I can't cut or paste or move all my file and folder in all my partition without system partition of Ubuntu.
I use Ubuntu 17.04.
I tried to search any response ...
20
votes
5
answers
75k
views
Cut command with word as delimiter
Is there any cut command to cut based on a word
eg :
171212 16082784 6264 XXX xxxxxxxx Transaction XXXXX abend ABCD. The task has terminated abnormally because of a program check. 16:08:27
...
1
vote
1
answer
2k
views
How to use cut command inside vim [closed]
I know this should be very simple but due to some reason I am not able to get this working.
say I have a simple file with multiple columns of data, I just want to get second column and remove other ...
1
vote
1
answer
99
views
How to create an alias to get a column? [duplicate]
Hello I would like to perform an alias to get an specific colum, parameter using a separator in order to achieve this i decided to use the cut command I created the alias as follows, and I saved it in ...
0
votes
3
answers
86
views
how to get the available space left deterministically?
When I use the cut command, everytime I get a different result which makes sense. So I wonder how to get the answer similar to this but consistent across different Ubuntu nodes?
ubuntu@ip:~/...
23
votes
4
answers
44k
views
Is there any way to make the cut command read the last field only?
I have a space seperated string which is output by a command, which I like to pipe to cut, using -fd ' ' to split on spaces. I know I can use -f <n> to display field number <n>, but can I ...
0
votes
0
answers
143
views
How to Assign a keyboard shortcut to a different combination?
I have an issue where my copy and paste keyboard shortcuts are assigned to ctrl + insert and shift + insert instead of ctrl + c and ctrl + v. Now that I am too used to using ctrl + v and ctrl + c, I ...
1
vote
2
answers
3k
views
Cut and store a string untill a word is found in bash
I have this string
/path/to/www/continued/xyz
I want to cut the string till www means I want the string
/path/to/www
How can I do this in bash
2
votes
2
answers
1k
views
How can I cut the mac address out of DHCPDUMP?
I am trying to use dhcpdump to recognize people logging onto my home network and give them a tailor made greeting using a credential file.
I cannot get the mac address out of the results of dhcpdump. ...
0
votes
1
answer
293
views
Periodically cut and paste files
I'm running a model that generates quite a stream of outputs. In fact they are so many that it ends up dying because the hard-drive is filled up
Is there a way (maybe with cron) to periodically scan ...
3
votes
1
answer
62
views
Store in environment variable
I tried storing the contents of a file in an environment variable using one of those commands.
a= cut -f 1 abc.txt
cut -f 1 abc.txt >a
neither works .
So , can anybody help me out?
0
votes
2
answers
354
views
How to use 'cut' command for finding temperature using tlp?
I have installed tlp in my system to prevent laptop over heating and i used this code to retrieve currtent cpu temperature.
tlp-stat -t
the output for above command is something like this:
--- TLP ...