New answers tagged macos
0
votes
Mac OS X Terminal Equivalent for Host Name Info
In addition to the hostname command in macOS's Terminal, you may also be interested by the following command:
/usr/sbin/networksetup -getcomputername
(They don't return the same field, hence they ...
2
votes
Replace last nonblank line with a command output
You could reverse the file and replace the first non-blank line
printf -v new_line 'CONFIG=%s' "$(jq -c . config.json)"
tac local.env \
| awk -v line="$new_line" '
!n &&...
1
vote
Accepted
Replace last nonblank line with a command output
I don't know about better (the best would be to know that it's the line that sets PARAM2 that needs replacing, but you specifically say "the last non-empty line"), but the ed editor is ...
1
vote
Write catalogue file names in to a file with additional string at the beginning end of a specific name
printf 'string1(%s)string2\n' *
Would print a string1(filename)string2 line for each of the non-hidden files in the current working directory, sorted lexically, or fail with an error if there was no ...
1
vote
Accepted
Write catalogue file names in to a file with additional string at the beginning end of a specific name
Adding a string to the beginning and end is quite easy:
$ ls
file1.txt file2.txt file3.txt
$ ls | sed -e 's/^/string1/' -e 's/$/string2/'
string1file1.txtstring2
string1file2.txtstring2
string1file3....
-1
votes
Accepted
bash get output from command
Because the output is on STDERR, the error file descriptor output.
What I would do, to combine STDOUT and STDERR in bash:
if softwareupdate -l 2>&1 | grep -q "No new software available&...
15
votes
Accepted
Why does `ls` in Linux and macOS show different owners (uid) for the same file?
From the Linux kernel documentation for the hfsplus module:
Mount options
uid=n, gid=n
Specifies the user/group that owns all files on the filesystem that have uninitialized permissions structures. ...
0
votes
Changing default editor for markdown bash_profile
How did you install "sublime text" on your Mac? Did you download the Mac version?
Since "open" on the Mac is unique to the Mac, this is more of a Mac "Finder" question .....
Top 50 recent answers are included
Related Tags
macos × 2749bash × 411
linux × 261
terminal × 244
shell-script × 164
zsh × 158
shell × 153
command-line × 145
ssh × 131
sed × 97
ubuntu × 95
files × 82
macintosh × 81
find × 75
permissions × 74
text-processing × 65
grep × 65
filesystems × 59
networking × 53
bsd × 48
awk × 47
ls × 45
path × 45
homebrew × 41
debian × 40