All Questions
123 questions
0
votes
2
answers
116
views
How to copy the value from one "column" to another in Bash?
I have a file with lines:
username="user1" email="[email protected]"
I need to take the username from the email address and replace the username value with it,
so the end result ...
-2
votes
2
answers
50
views
Remove last 9 character in alternate lines of file in unix
I need to remove last 9 character from a file starting from Line number 4 and remove only on alternate lines 6,8.. like that to last Line of file
1
vote
2
answers
71
views
Use sed to insert a character in an xml file
I have an xml file with content following this format:
<type:color>000000</type:color>
<type:color>FFFFFF</type:color>
The information within the tags are hex colors (many ...
16
votes
5
answers
1k
views
How can UserA programmatically replace a text string within a file they own that's located in /etc?
A non-root linux user owns a text file that's located in /etc, where the non-root linux user does not have permission to create files. The non-root linux user can edit the file manually via vi without ...
0
votes
2
answers
81
views
extract a column from the command output even if it blank bash
I am trying to extract 2nd column from a command output
For example:
$ sudo /usr/sbin/pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 vgswap lvm2 a-- 16.00g 0
/dev/sdc2 ...
0
votes
0
answers
21
views
Non-column output of `ls` piped to `sed` [duplicate]
As far as I know, command sed precesses its input line by line. Thus, the following command successfully outputs only the directories in the current directory:
$ ls -p -1 | sed -n '/\/$/p'
Here ...
-1
votes
3
answers
129
views
sed inline not working to modify XML-style input
the problem is that I cannot put the complete command on a line with SED, I had already done it but with those file it does not work:
my exemple :
<file>Documents/time/text1</file> //2X ...
0
votes
3
answers
128
views
Rename multiple files in directory - Using sed or rename command
I have tried so many different sed, mv and rename commands - still I cannot rename these files. There are 50 plus files - I tried commands I found - Help thx
Original filenames:
PAGES_TEST1_SART1.XML
...
1
vote
1
answer
72
views
Sed - replace a string with a character of another line
I am trying to write a script to reformat some text.
pages:
page1:
gui-rows: 6
items:
'6':
material: CAT_SPAWN_EGG
buy: 999999999
sell: -1
'7':
...
-2
votes
3
answers
127
views
bash + how to verify folders under specific path are ended with number/s
I want to check the folder/s under /var/kafka that all them are ended with number otherwhile I will exit with error
ls -ltr /var/kafka
drwxr-xr-x 399 kafka kafka 28672 Nov 9 13:10 data6
drwxr-xr-x ...
0
votes
3
answers
563
views
How to make bash not assign a \n to a variable?
I have a variable that goes more or less like this:
$ echo "$LIST"
file1: ok
file2: ok
file3:
file4:
file5: ok
Then I need to get the list of files that are not ok:
$ sed '/:\s.\+$/d' <&...
0
votes
2
answers
49
views
How do I use the Sed command to match on everything between two patterns?
This is an example of a row pf data from the CSV file that I'm parsing.
"Monday, July 3, 2023 at 9:12:34 PM GMT+0:00","Answer 1","Answer 2","Answer 3"
I'm ...
4
votes
4
answers
993
views
Combining every 3 lines together starting on the second line, and removing first column from second and third line being combined
I am very new to unix as well as coding in general and have spent a long time trying to figure out this issue with no success. I am sure its a very simple solution but if someone can help point me in ...
2
votes
2
answers
2k
views
Sed based on 2 words, then replace whole line with variable
I have a txt file looking like this,
1:Ana:apple:08:00:wait
1:Joe:banana:08:30:wait
1:Oscar:orange:08:45:ready
1:Monica:apple:08:50:ready
1:Mark::orange:ready
I have to find only the first line that ...
0
votes
0
answers
130
views
Can't get sed command to work in inline file update mode
This sed command works when output to the terminal:
for FILE in *.cs; do NEW_VERS="$(cat $FILE | awk '/%version:/{print $(NF-1)}')"; sed -e "/Revision.*/,/using/{/\/\/.[\*]*[\*]$/i \\/\/...