Skip to main content
Add warning about aliases
Source Link
xenoid
  • 9.3k
  • 4
  • 29
  • 52

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

Some will say that in a script it is best to use grep -E instead of egrep

PS: An aliased command will work in the command prompt/terminal but not in a script, so trying the command in the terminal isn't proof that it will work in a script. In bash, use type {commandname} to check if the name is a real command or an alias. egrep can be implemented as an alias in some Unix versions, in my Ubuntu it is a plain command.

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

Some will say that in a script it is best to use grep -E instead of egrep

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

Some will say that in a script it is best to use grep -E instead of egrep

PS: An aliased command will work in the command prompt/terminal but not in a script, so trying the command in the terminal isn't proof that it will work in a script. In bash, use type {commandname} to check if the name is a real command or an alias. egrep can be implemented as an alias in some Unix versions, in my Ubuntu it is a plain command.

added 79 characters in body
Source Link
xenoid
  • 9.3k
  • 4
  • 29
  • 52

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

Some will say that in a script it is best to use grep -E instead of egrep

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

Some will say that in a script it is best to use grep -E instead of egrep

Rollback to Revision 1
Source Link
xenoid
  • 9.3k
  • 4
  • 29
  • 52

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| grep -Eegrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| grep -Eegrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| grep -E "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| grep -E "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

As it says on the tin. You create a command name which is egrep '2019-05-11|Total' and then try to call it. This is not a egrep followed by a parameter but a complete command name. What you want is more likely:

totalSize=$(echo $s3ls| egrep "$currentDate|Total" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')

If necessary you can use a variable to hold the parameter:

egrepParm="$currentDate|Total" 
totalSize=$(echo $s3ls| egrep "$egrepParm" | awk -F 'Total Size:' '{print $2}'|sed '/^$/d')
The egrep/fgrep etc commands are just aliases and POSIX defined the grep -E (http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html)
Source Link
terdon
  • 252.4k
  • 69
  • 480
  • 718
Loading
Source Link
xenoid
  • 9.3k
  • 4
  • 29
  • 52
Loading