Fish Shell to Truncate list of files
up vote
1
down vote
favorite
In bash if I wish to truncate a bunch of files in a directory, I would do the following:
for i in *
do
cat /dev/null > $i
done
In fish, I tried:
for I in *
cat /dev/null > $I
end
but that gives me the error:
fish: Invalid redirection target: $I
So anyone know how to achieve this?
Thanks.
fish
add a comment |
up vote
1
down vote
favorite
In bash if I wish to truncate a bunch of files in a directory, I would do the following:
for i in *
do
cat /dev/null > $i
done
In fish, I tried:
for I in *
cat /dev/null > $I
end
but that gives me the error:
fish: Invalid redirection target: $I
So anyone know how to achieve this?
Thanks.
fish
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In bash if I wish to truncate a bunch of files in a directory, I would do the following:
for i in *
do
cat /dev/null > $i
done
In fish, I tried:
for I in *
cat /dev/null > $I
end
but that gives me the error:
fish: Invalid redirection target: $I
So anyone know how to achieve this?
Thanks.
fish
In bash if I wish to truncate a bunch of files in a directory, I would do the following:
for i in *
do
cat /dev/null > $i
done
In fish, I tried:
for I in *
cat /dev/null > $I
end
but that gives me the error:
fish: Invalid redirection target: $I
So anyone know how to achieve this?
Thanks.
fish
fish
asked Nov 8 at 19:55
Todd
347314
347314
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Works for me. Note that the only way you'll get that error is if variable I
is not set. I noticed you used a lowercase letter for your bash example and uppercase for the fish example. Did you perhaps mix the case? For example, this will cause the error you saw:
for i in *
true > $I
end
P.S., In a POSIX shell it's more efficient to do : > $i
. Since fish doesn't support :
it's more efficient to do true > $i
to avoid spawning an external command and opening /dev/null.
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Works for me. Note that the only way you'll get that error is if variable I
is not set. I noticed you used a lowercase letter for your bash example and uppercase for the fish example. Did you perhaps mix the case? For example, this will cause the error you saw:
for i in *
true > $I
end
P.S., In a POSIX shell it's more efficient to do : > $i
. Since fish doesn't support :
it's more efficient to do true > $i
to avoid spawning an external command and opening /dev/null.
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
add a comment |
up vote
4
down vote
accepted
Works for me. Note that the only way you'll get that error is if variable I
is not set. I noticed you used a lowercase letter for your bash example and uppercase for the fish example. Did you perhaps mix the case? For example, this will cause the error you saw:
for i in *
true > $I
end
P.S., In a POSIX shell it's more efficient to do : > $i
. Since fish doesn't support :
it's more efficient to do true > $i
to avoid spawning an external command and opening /dev/null.
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Works for me. Note that the only way you'll get that error is if variable I
is not set. I noticed you used a lowercase letter for your bash example and uppercase for the fish example. Did you perhaps mix the case? For example, this will cause the error you saw:
for i in *
true > $I
end
P.S., In a POSIX shell it's more efficient to do : > $i
. Since fish doesn't support :
it's more efficient to do true > $i
to avoid spawning an external command and opening /dev/null.
Works for me. Note that the only way you'll get that error is if variable I
is not set. I noticed you used a lowercase letter for your bash example and uppercase for the fish example. Did you perhaps mix the case? For example, this will cause the error you saw:
for i in *
true > $I
end
P.S., In a POSIX shell it's more efficient to do : > $i
. Since fish doesn't support :
it's more efficient to do true > $i
to avoid spawning an external command and opening /dev/null.
answered Nov 8 at 20:33
Kurtis Rader
2,899510
2,899510
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
add a comment |
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
I used I in the fish example to differ it from the bash example. But I think you are correct, I noticed when typing it in again, that fish was changing the case of my variable names as I typed. weird. thanks for the sanity check.
– Todd
Nov 8 at 20:39
add a comment |
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%2fstackoverflow.com%2fquestions%2f53215210%2ffish-shell-to-truncate-list-of-files%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