Aliased an awk command successfully now won't use OFS [closed]

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!
alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"
A variation of the above is what I put into my alias.
command-line quoting alias
closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm⦠Jun 28 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |Â
up vote
1
down vote
favorite
So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!
alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"
A variation of the above is what I put into my alias.
command-line quoting alias
closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm⦠Jun 28 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
What's the alias?
â Kusalananda
Jun 27 at 20:20
edited this to show the alias.
â trazinaz
Jun 27 at 21:04
I'm not sure why you have the backslash beforeOFS, but I also can't see any problems with that, with or without the backslash.
â ilkkachu
Jun 27 at 21:14
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!
alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"
A variation of the above is what I put into my alias.
command-line quoting alias
So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:
find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '
So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!
alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"
A variation of the above is what I put into my alias.
command-line quoting alias
edited Jun 27 at 21:01
ilkkachu
47.3k668130
47.3k668130
asked Jun 27 at 20:19
trazinaz
262
262
closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm⦠Jun 28 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm⦠Jun 28 at 3:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
What's the alias?
â Kusalananda
Jun 27 at 20:20
edited this to show the alias.
â trazinaz
Jun 27 at 21:04
I'm not sure why you have the backslash beforeOFS, but I also can't see any problems with that, with or without the backslash.
â ilkkachu
Jun 27 at 21:14
add a comment |Â
2
What's the alias?
â Kusalananda
Jun 27 at 20:20
edited this to show the alias.
â trazinaz
Jun 27 at 21:04
I'm not sure why you have the backslash beforeOFS, but I also can't see any problems with that, with or without the backslash.
â ilkkachu
Jun 27 at 21:14
2
2
What's the alias?
â Kusalananda
Jun 27 at 20:20
What's the alias?
â Kusalananda
Jun 27 at 20:20
edited this to show the alias.
â trazinaz
Jun 27 at 21:04
edited this to show the alias.
â trazinaz
Jun 27 at 21:04
I'm not sure why you have the backslash before
OFS, but I also can't see any problems with that, with or without the backslash.â ilkkachu
Jun 27 at 21:14
I'm not sure why you have the backslash before
OFS, but I also can't see any problems with that, with or without the backslash.â ilkkachu
Jun 27 at 21:14
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
If you do:
alias foo="...'print $5 $1 $2 $3 '"
The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.
That n should be fine within the double quotes, though.
In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.
mycommand()
sort
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you do:
alias foo="...'print $5 $1 $2 $3 '"
The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.
That n should be fine within the double quotes, though.
In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.
mycommand()
sort
add a comment |Â
up vote
0
down vote
If you do:
alias foo="...'print $5 $1 $2 $3 '"
The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.
That n should be fine within the double quotes, though.
In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.
mycommand()
sort
add a comment |Â
up vote
0
down vote
up vote
0
down vote
If you do:
alias foo="...'print $5 $1 $2 $3 '"
The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.
That n should be fine within the double quotes, though.
In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.
mycommand()
sort
If you do:
alias foo="...'print $5 $1 $2 $3 '"
The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.
That n should be fine within the double quotes, though.
In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.
mycommand()
sort
answered Jun 27 at 21:11
ilkkachu
47.3k668130
47.3k668130
add a comment |Â
add a comment |Â
2
What's the alias?
â Kusalananda
Jun 27 at 20:20
edited this to show the alias.
â trazinaz
Jun 27 at 21:04
I'm not sure why you have the backslash before
OFS, but I also can't see any problems with that, with or without the backslash.â ilkkachu
Jun 27 at 21:14