Skip to main content
replace rude/offensive/unnecessary/inaccurate language with a more appropriate and accurate equivalent
Source Link

Here's a sleek one:

printf %s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

printf %s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwedmessed up.

some credit to:

Here's a sleek one:

printf %s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

printf %s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

Here's a sleek one:

printf %s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

printf %s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be messed up.

some credit to:

Rollback to Revision 4
Source Link
akostadinov
  • 1.2k
  • 12
  • 21

Here's a sleek one:

echoprintf -n%s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

echoprintf -n%s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`echoPATH=`printf -n%s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

Here's a sleek one:

echo -n "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

echo -n "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`echo -n "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

Here's a sleek one:

printf %s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

printf %s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

added 6 characters in body
Source Link
akostadinov
  • 1.2k
  • 12
  • 21

Here's a sleek one:

printfecho %s-n "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

printfecho %s-n "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`printfPATH=`echo %s-n "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

Here's a sleek one:

printf %s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

printf %s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

Here's a sleek one:

echo -n "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' 

Longer (to see how it works):

echo -n "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' 

Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"

PATH=`echo -n "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 

btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwed.

some credit to:

don't break on spaces and backslashes
Source Link
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k
Loading
echo -n
Source Link
akostadinov
  • 1.2k
  • 12
  • 21
Loading
actual command to achieve the desired result
Source Link
akostadinov
  • 1.2k
  • 12
  • 21
Loading
Source Link
akostadinov
  • 1.2k
  • 12
  • 21
Loading