Search Results

Search: Posts Made By: LMHmedchem
327
Posted By RudiC
Nice approach indeed! Could be curtailed to ...
Nice approach indeed!
Could be curtailed to
sed -r "/'($(paste -sd\| file2))'/s/^C//" file1, including the item list file as well.
327
Posted By rbatte1
One line sed option
How about using a single line sed like this:-sed "s/^C\( CALL.*'\(Gmax\|Gmin\|HS10\|HS2\|HS9\|Hmax\)'.*\)/\1/" source_file_name > target_file_name

It's a little messy to read, so:-

The s...
327
Posted By MadeInGermany
Or do all in bash - here is a well documented...
Or do all in bash - here is a well documented bash version:
#! /bin/bash
# bash v3 or higher

# file with list of items to find in modify_file
list_file=$1
# file for which a modified copy will...
327
Posted By RudiC
Try awk -v"SQ='" ' FNR == NR ...
Try


awk -v"SQ='" '
FNR == NR {PAT[NR]="^C.*" SQ $0 SQ
MX = NR
next
}
{for (i=1; i<=MX; i++) if ($0 ~ PAT[i]) {sub...
2,738
Posted By MadeInGermany
The RE searches require some quoting effort. ...
The RE searches require some quoting effort.
The index() function searches for plain strings and returns the position.
Also only the comments left from the search string matter.
Two reasons to go...
472
Posted By RudiC
Making some assumptions on your data structure...
Making some assumptions on your data structure (until Don Cragun's questions have been fully and finally answered), and making up my own sample data files, I have come up with
awk '
BEGIN ...
472
Posted By Don Cragun
In post #1, the labels in your sample input files...
In post #1, the labels in your sample input files were "train statistics" and "test statistics". In your latest code you have labels with underscores instead of spaces. You'll have to be sure your...
564
Posted By johnprogrammer
Shutdown is a system-wide action, and requires...
Shutdown is a system-wide action, and requires root privileges in some UNIX systems (macOS included).

This means, if you want to have shutdown as an option in a script, you will need to give the...
564
Posted By Neo
No, you are not really correct. I have 4 Macs...
No, you are not really correct. I have 4 Macs which I work on extensively, and I do not use MacOS as you describe. When I login as "Neo", which is a user account with MacOS Admin rights, I do not...
564
Posted By Neo
You don't need to sudo, just run it from the...
You don't need to sudo, just run it from the admin account on the Mac and move on to other tasks.

That way the script stays the same and you don't need to be bothered using sudo to run a simple,...
564
Posted By bakunin
First off, i can only emphasize what Neo already...
First off, i can only emphasize what Neo already said. This is the best solution from a practical POV. But since you may want to understand your system better i will try to explain what happened...
264
Posted By johnprogrammer
Here is POSIX shell compliant code, that returns...
Here is POSIX shell compliant code, that returns the full path of a file or directory.


#!/bin/sh

# FullPath subroutine, version 1.0, POSIX shell compliant.

# Copyright © 2019 Ioannis...
264
Posted By Don Cragun
It should be stable as long as you double-click...
It should be stable as long as you double-click on a link to invoke your script (as long as you don't change the way you create the link, change any configuration variables that control how links are...
564
Posted By johnprogrammer
It is a macOS thing. You must right click on the...
It is a macOS thing. You must right click on the Terminal icon on the Dock, and select Quit.

See the screenshot attached.
564
Posted By Neo
There is an option in the MacOS terminal to close...
There is an option in the MacOS terminal to close the window when the shell exits. That is what I use.

https://www.unix.com/members/1-albums233-picture1129.png
564
Posted By Corona688
My apologies for not investigating this the other...
My apologies for not investigating this the other day, I forgot all about it.

exit does have an option for exactly the purpose of informing the thing which called it, it returns a number 0 for...
564
Posted By Don Cragun
Ah, yes. I see! You name your shell script...
Ah, yes. I see!

You name your shell script rsync_data_backup.sh and you have problems.

I name my shell script rsync_data_backup and it works just fine.

I don't know why, but having the...
564
Posted By Don Cragun
Hi LMHMedchem, What initiates the backup script...
Hi LMHMedchem,
What initiates the backup script in the window it runs in on Windows under cygwin?

What initiates the backup script in the window it runs in on macOS?

How was the window in...
564
Posted By Corona688
This is a Mac OS thing, not a bash thing. I'll...
This is a Mac OS thing, not a bash thing. I'll take a look at mine when I get home tonight.
592
Posted By Don Cragun
Hi Jim, The standard csplit synopsis is more...
Hi Jim,
The standard csplit synopsis is more like:
csplit [−ks] [−f prefix] [−n number] file /BRE/[offset]...
Note that the patterns with optional offsets (i.e., /BRE/[offset]) come after the file...
592
Posted By jim mcnamara
Note: the csplit syntax is incorrect Ignore the...
Note: the csplit syntax is incorrect Ignore the example. See Don Cragun's post below
Have you looked at the csplit command? It works by context (context split), and the split is based on a string...
544
Posted By Don Cragun
Hi LMHmedchem, Well done. I see no reason why...
Hi LMHmedchem,
Well done. I see no reason why the code you have will not meet your requirements.

You might want to consider this alternative that should be slightly faster (since it doesn't...
734
Posted By Chubler_XL
This solution as 1 awk program appears to work OK...
This solution as 1 awk program appears to work OK with your test data.

Note: I used index() and substr() instead of gsub() to avoid possible RE character issues that MadeInGermany identified.

#...
734
Posted By MadeInGermany
Your #1 problem is that your output file is...
Your #1 problem is that your output file is overwritten by each loop cycle, so will only contain the last sed output.
Your #2 problem is that [ ] are RE-special characters.
(While the ( ) are only...
734
Posted By RudiC
Give this a try with a few different input files ...
Give this a try with a few different input files
awk '
function PRT() {TMP = $0
for (i=1; i<=MXLN; i++) {$0 = LINE[i]
if...
Showing results 1 to 25 of 161

 
All times are GMT -4. The time now is 04:44 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy