SED not exiting The Next CEO of Stack OverflowWhy *not* parse `ls` (and what do to instead)?SED not Deleting linesSSH command not exiting properlyInvalid command code with sedExiting a running script with any buttonsed error: “1 not defined in the RE” under OS Xsed command not substituting properlySed not workingSed and BBedit Htmlsed command in script function not working?Programmatically closing pipeline / exiting
Are there languages with no euphemisms?
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
How can I quit an app using Terminal?
Rotate a column
Where to find order of arguments for default functions
Is the concept of a "numerable" fiber bundle really useful or an empty generalization?
How do I construct this japanese bowl?
Why did we only see the N-1 starfighters in one film?
What does "Its cash flow is deeply negative" mean?
Is it a good idea to use COLUMN AS (left([Another_Column],(4)) instead of LEFT in the select?
Why were Madagascar and New Zealand discovered so late?
Trouble understanding the speech of overseas colleagues
Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?
Why is there a PLL in CPU?
MAZDA 3 2006 (UK) - poor acceleration then takes off at 3250 revs
Return the Closest Prime Number
How to safely derail a train during transit?
What can we do to stop prior company from asking us questions?
Too much space between section and text in a twocolumn document
What happens if you roll doubles 3 times then land on "Go to jail?"
Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables
How to count occurrences of text in a file?
Can I equip Skullclamp on a creature I am sacrificing?
Science fiction (dystopian) short story set after WWIII
SED not exiting
The Next CEO of Stack OverflowWhy *not* parse `ls` (and what do to instead)?SED not Deleting linesSSH command not exiting properlyInvalid command code with sedExiting a running script with any buttonsed error: “1 not defined in the RE” under OS Xsed command not substituting properlySed not workingSed and BBedit Htmlsed command in script function not working?Programmatically closing pipeline / exiting
All,I used following piece of code to list down the contents of a directory in macOS:
#!/bin/bash
echo "hello User"
echo ""
userdir=$1
var_one=$userdir/Library/Application Support/iCloud/Accounts/
if [ -d "$var_one" ]
then
# echo "Direcotry exists"
echo "The AppleID is : "
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
echo "~~~~~~~BYE~~~~~~"
break
else
echo "Directory doesn't exists"
echo "The path is $var_one"
fi
If the directory exists then sed command is used along with regex pattern to identify the desired file. The script works fine but doesn't seem to exit. I am new to this and might be missing out important bits & pieces. Any suggestions/codes for further improvement are welcome.
bash shell-script sed osx apple
add a comment |
All,I used following piece of code to list down the contents of a directory in macOS:
#!/bin/bash
echo "hello User"
echo ""
userdir=$1
var_one=$userdir/Library/Application Support/iCloud/Accounts/
if [ -d "$var_one" ]
then
# echo "Direcotry exists"
echo "The AppleID is : "
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
echo "~~~~~~~BYE~~~~~~"
break
else
echo "Directory doesn't exists"
echo "The path is $var_one"
fi
If the directory exists then sed command is used along with regex pattern to identify the desired file. The script works fine but doesn't seem to exit. I am new to this and might be missing out important bits & pieces. Any suggestions/codes for further improvement are welcome.
bash shell-script sed osx apple
1
there is no input to sed command, sed is waiting onSTDIN
– Archemar
yesterday
Few comments: * You dont need to escape the/
. You just need to escape the spaces. * break is only valid in loops.
– Mike V.D.C.
yesterday
1
Also, if you're on macOS,sed
is unlikely to know whatw
is (macOSsed
does not know PCRE expressions). Instead, use[[:alnum:]_]
(this is a POSIX character class equivalent tow
).
– Kusalananda♦
yesterday
add a comment |
All,I used following piece of code to list down the contents of a directory in macOS:
#!/bin/bash
echo "hello User"
echo ""
userdir=$1
var_one=$userdir/Library/Application Support/iCloud/Accounts/
if [ -d "$var_one" ]
then
# echo "Direcotry exists"
echo "The AppleID is : "
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
echo "~~~~~~~BYE~~~~~~"
break
else
echo "Directory doesn't exists"
echo "The path is $var_one"
fi
If the directory exists then sed command is used along with regex pattern to identify the desired file. The script works fine but doesn't seem to exit. I am new to this and might be missing out important bits & pieces. Any suggestions/codes for further improvement are welcome.
bash shell-script sed osx apple
All,I used following piece of code to list down the contents of a directory in macOS:
#!/bin/bash
echo "hello User"
echo ""
userdir=$1
var_one=$userdir/Library/Application Support/iCloud/Accounts/
if [ -d "$var_one" ]
then
# echo "Direcotry exists"
echo "The AppleID is : "
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
echo "~~~~~~~BYE~~~~~~"
break
else
echo "Directory doesn't exists"
echo "The path is $var_one"
fi
If the directory exists then sed command is used along with regex pattern to identify the desired file. The script works fine but doesn't seem to exit. I am new to this and might be missing out important bits & pieces. Any suggestions/codes for further improvement are welcome.
bash shell-script sed osx apple
bash shell-script sed osx apple
edited yesterday
h k
94
94
asked yesterday
swasti bhushan debswasti bhushan deb
63
63
1
there is no input to sed command, sed is waiting onSTDIN
– Archemar
yesterday
Few comments: * You dont need to escape the/
. You just need to escape the spaces. * break is only valid in loops.
– Mike V.D.C.
yesterday
1
Also, if you're on macOS,sed
is unlikely to know whatw
is (macOSsed
does not know PCRE expressions). Instead, use[[:alnum:]_]
(this is a POSIX character class equivalent tow
).
– Kusalananda♦
yesterday
add a comment |
1
there is no input to sed command, sed is waiting onSTDIN
– Archemar
yesterday
Few comments: * You dont need to escape the/
. You just need to escape the spaces. * break is only valid in loops.
– Mike V.D.C.
yesterday
1
Also, if you're on macOS,sed
is unlikely to know whatw
is (macOSsed
does not know PCRE expressions). Instead, use[[:alnum:]_]
(this is a POSIX character class equivalent tow
).
– Kusalananda♦
yesterday
1
1
there is no input to sed command, sed is waiting on
STDIN
– Archemar
yesterday
there is no input to sed command, sed is waiting on
STDIN
– Archemar
yesterday
Few comments: * You dont need to escape the
/
. You just need to escape the spaces. * break is only valid in loops.– Mike V.D.C.
yesterday
Few comments: * You dont need to escape the
/
. You just need to escape the spaces. * break is only valid in loops.– Mike V.D.C.
yesterday
1
1
Also, if you're on macOS,
sed
is unlikely to know what w
is (macOS sed
does not know PCRE expressions). Instead, use [[:alnum:]_]
(this is a POSIX character class equivalent to w
).– Kusalananda♦
yesterday
Also, if you're on macOS,
sed
is unlikely to know what w
is (macOS sed
does not know PCRE expressions). Instead, use [[:alnum:]_]
(this is a POSIX character class equivalent to w
).– Kusalananda♦
yesterday
add a comment |
2 Answers
2
active
oldest
votes
Try replacing:
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
With something like this:
ls "$var_one" | sed -n '2/[*w-]+@([w-]+.)+[w-]+/p'
See also: Why not parse ls
(and what do to instead)?
add a comment |
There's a few things that could be improved in your script.
First of all, the sed
doesn't do anything because it's not receiving any input. This means that it will just sit there waiting for you to type things on the keyboard into its standard input stream. Additionally, don't use sed
or other text editing tools (awk
etc.) on filenames. Filenames on Unix systems can, contain newlines, and sed
(for example) reads individual lines, which means it would read a filename with an embedded newline as two separate things.
It's uncommon for filenames to contain newlines, but if a script don't take this into account, a malicious user may possibly use this fact to confuse the script into doing things it wasn't designed to do.
To find the currently signed in Apple ID, rather than using some heuristic approach, use a tool that can do it for you. With Homebrew, you may install mas
:
brew install mas
Then,
mas account
will give you the currently signed in Apple ID.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508884%2fsed-not-exiting%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try replacing:
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
With something like this:
ls "$var_one" | sed -n '2/[*w-]+@([w-]+.)+[w-]+/p'
See also: Why not parse ls
(and what do to instead)?
add a comment |
Try replacing:
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
With something like this:
ls "$var_one" | sed -n '2/[*w-]+@([w-]+.)+[w-]+/p'
See also: Why not parse ls
(and what do to instead)?
add a comment |
Try replacing:
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
With something like this:
ls "$var_one" | sed -n '2/[*w-]+@([w-]+.)+[w-]+/p'
See also: Why not parse ls
(and what do to instead)?
Try replacing:
sed -n '/[*w-]+@([w-]+.)+[w-]+/p'|ls "$var_one"|awk NR==2'print'
With something like this:
ls "$var_one" | sed -n '2/[*w-]+@([w-]+.)+[w-]+/p'
See also: Why not parse ls
(and what do to instead)?
answered yesterday
agcagc
4,72711138
4,72711138
add a comment |
add a comment |
There's a few things that could be improved in your script.
First of all, the sed
doesn't do anything because it's not receiving any input. This means that it will just sit there waiting for you to type things on the keyboard into its standard input stream. Additionally, don't use sed
or other text editing tools (awk
etc.) on filenames. Filenames on Unix systems can, contain newlines, and sed
(for example) reads individual lines, which means it would read a filename with an embedded newline as two separate things.
It's uncommon for filenames to contain newlines, but if a script don't take this into account, a malicious user may possibly use this fact to confuse the script into doing things it wasn't designed to do.
To find the currently signed in Apple ID, rather than using some heuristic approach, use a tool that can do it for you. With Homebrew, you may install mas
:
brew install mas
Then,
mas account
will give you the currently signed in Apple ID.
add a comment |
There's a few things that could be improved in your script.
First of all, the sed
doesn't do anything because it's not receiving any input. This means that it will just sit there waiting for you to type things on the keyboard into its standard input stream. Additionally, don't use sed
or other text editing tools (awk
etc.) on filenames. Filenames on Unix systems can, contain newlines, and sed
(for example) reads individual lines, which means it would read a filename with an embedded newline as two separate things.
It's uncommon for filenames to contain newlines, but if a script don't take this into account, a malicious user may possibly use this fact to confuse the script into doing things it wasn't designed to do.
To find the currently signed in Apple ID, rather than using some heuristic approach, use a tool that can do it for you. With Homebrew, you may install mas
:
brew install mas
Then,
mas account
will give you the currently signed in Apple ID.
add a comment |
There's a few things that could be improved in your script.
First of all, the sed
doesn't do anything because it's not receiving any input. This means that it will just sit there waiting for you to type things on the keyboard into its standard input stream. Additionally, don't use sed
or other text editing tools (awk
etc.) on filenames. Filenames on Unix systems can, contain newlines, and sed
(for example) reads individual lines, which means it would read a filename with an embedded newline as two separate things.
It's uncommon for filenames to contain newlines, but if a script don't take this into account, a malicious user may possibly use this fact to confuse the script into doing things it wasn't designed to do.
To find the currently signed in Apple ID, rather than using some heuristic approach, use a tool that can do it for you. With Homebrew, you may install mas
:
brew install mas
Then,
mas account
will give you the currently signed in Apple ID.
There's a few things that could be improved in your script.
First of all, the sed
doesn't do anything because it's not receiving any input. This means that it will just sit there waiting for you to type things on the keyboard into its standard input stream. Additionally, don't use sed
or other text editing tools (awk
etc.) on filenames. Filenames on Unix systems can, contain newlines, and sed
(for example) reads individual lines, which means it would read a filename with an embedded newline as two separate things.
It's uncommon for filenames to contain newlines, but if a script don't take this into account, a malicious user may possibly use this fact to confuse the script into doing things it wasn't designed to do.
To find the currently signed in Apple ID, rather than using some heuristic approach, use a tool that can do it for you. With Homebrew, you may install mas
:
brew install mas
Then,
mas account
will give you the currently signed in Apple ID.
answered yesterday
Kusalananda♦Kusalananda
138k17258426
138k17258426
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508884%2fsed-not-exiting%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
there is no input to sed command, sed is waiting on
STDIN
– Archemar
yesterday
Few comments: * You dont need to escape the
/
. You just need to escape the spaces. * break is only valid in loops.– Mike V.D.C.
yesterday
1
Also, if you're on macOS,
sed
is unlikely to know whatw
is (macOSsed
does not know PCRE expressions). Instead, use[[:alnum:]_]
(this is a POSIX character class equivalent tow
).– Kusalananda♦
yesterday