Need to split the $PATH output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to split the $PATH output
# 1  
Old 11-20-2010
Need to split the $PATH output

Hi,

/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

i want to print the above output as below

/usr/kerberos/sbin
/usr/kerberos/bin
/usr/local/sbin
/usr/local/bin
/sbin
/bin
/usr/sbin
/usr/bin
/usr/X11R6/bin
/root/bin

Need help.
# 2  
Old 11-20-2010
Code:
echo $PATH | tr ':' '\n'

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 11-20-2010
Code:
echo $PATH | awk '1' RS=":"

# 4  
Old 11-20-2010
Thank you very much for your swift response.
# 5  
Old 11-20-2010
Code:
( IFS=: ; printf "%s\n" $PATH )


Last edited by Scrutinizer; 11-21-2010 at 12:16 AM..
# 6  
Old 11-20-2010
Code:
echo $PATH | sed 's/:/\n/g'
echo $PATH | perl -plne 's/:/\n/g'

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Split Command Generating Incomplete Output Files

Hello All, May i please know how do i ensure my split command would NOT generate incomplete output files like below, the last lines in each file is missing some columns or last line is complete. split -b 50GB File File_ File_aa |551|70210203|xxxxxxx|12/22/2010 20:44:58|11/01/2010... (1 Reply)
Discussion started by: Ariean
1 Replies

2. UNIX for Dummies Questions & Answers

Extract name from path and change output

Dear All, I would like to extract the file name without extension form a variable... In particular I have a command like this one: for file in path/to/file/example_number.ext do something -input $file -output ${file%_number.ext}.new done means that in variable $file are saved all the path... (3 Replies)
Discussion started by: giuliangiuseppe
3 Replies

3. Shell Programming and Scripting

awk : split file and rename and save in path according to content

Hello, I'm using Windows 7 ; sed, awk and gnuwin32 are installed. I have a big text file I need to manipulate. In short, I will have to split it in thousands of short files, then rename and save in a folder which name is based upon filename. Here is a snippet of my big input.txt file (this... (4 Replies)
Discussion started by: sellig
4 Replies

4. Shell Programming and Scripting

How to split the sql output into two different variables

Hi, How to set as variable from sql output. Query: select aa.serial, ao.name from ann_amit aa JOIN ann_object ao on (aa.classid=ao.classid); I got two values from aa.serial and ao.name, I wanna make two different variable for aa.serial and ao.name. The value of aa.serial should be in... (2 Replies)
Discussion started by: KarthikPS
2 Replies

5. Shell Programming and Scripting

renaming the default output name of the split command

Hello, I would like to split a file but I dont what the subfiles to be named the way they are: ex: default name: xaa xab xac xad xae desired name: b01 b02 b03 b04 b05 I know I can rename them afterwards however I have a varialbe split lenghth, in other words I am not sure how... (2 Replies)
Discussion started by: smarones
2 Replies

6. Shell Programming and Scripting

Split Filename from Absolute Path

Hello, I have the string "/a/b/c/ddd.txt" and i want to get only the filename, in this case "ddd.txt". I have as something known in the script the pattern "/a/b/c/", so I`ve tried something like: echo "/a/b/c/ddd.txt" | cut -d "/a/b/c/" -f2 but it doesn`t go, any help?. thanks, bye (2 Replies)
Discussion started by: rubber08
2 Replies

7. Shell Programming and Scripting

No need path in output of LS command

hi, while i am placing the command. ls /app/callidus/rci_vst_p1/vst_fact_sms_cdr* I am getting the below ouput.. Output /app/callidus/rci_vst_p1/Inbound/vst_fact_sms_cdr_20101124.dat /app/callidus/rci_vst_p1/Inbound/vst_fact_sms_cdr_20101215.dat... (4 Replies)
Discussion started by: rsivasan
4 Replies

8. Shell Programming and Scripting

Split function input and output order

Dear Forum I'm Trying to use split function to split a string, but the output is not as the same order as of the string, please see simple example echo " " | nawk -v var="First;Second;Third;Fourth" ' BEGIN {split(var, arr,";") for(i in arr){print arr }}' The output is Second Third... (6 Replies)
Discussion started by: yahyaaa
6 Replies

9. Shell Programming and Scripting

how to get split output of a file, using perl script

Hi, I have file: data.log.1 ### s1 main.build.3495 main.build.199 main.build.3408 ###s2 main.build.3495 main.build.3408 main.build.199 I want to read this file and store in two arrays in Perl. I have following command, which is working fine on command prompt. perl -n -e... (1 Reply)
Discussion started by: ashvini
1 Replies

10. Shell Programming and Scripting

split and print $PATH

Hello simple question : how can i split the $PATH by the ":" seperator with one liner ? mybe using awk is there any builtin function in awk that splits and prints the output ? thanks (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question