split and print $PATH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting split and print $PATH
# 1  
Old 06-06-2006
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  
Old 06-06-2006
Code:
echo $PATH | tr -s ':' '\n'

# 3  
Old 06-06-2006
for i in `echo $PATH | sed "s/:/ /g"`
do
echo $i
done

If you want to process the lines rather than just output them, replace echo with the processing.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

A way to print only part of directory path

Hi, So I struggled to find a solution to the following problem: I want to make sed print only part of multiple different paths. So lets say we have /path/path1/path2/logs/bla/blabla /path/path1/path2/path3/logs/yadda/yadda/yadda Can someone suggest a way to make sed or other... (5 Replies)
Discussion started by: dampio
5 Replies

2. Shell Programming and Scripting

Awk, split, print

How to print the split array elements in the same line with awk? echo "1 2 3 4 /path/to/file1" | awk 'split($5, A, "/") {print $0; for (i=1; i<=length(A); i++) print A}' echo "2 2 3 6 /longer/path/to/another/file2" | awk 'split($5, A, "/") {print $0; for (i=1; i<=length(A); i++) print A}' What... (6 Replies)
Discussion started by: yifangt
6 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

awk to split one field and print the last two fields within the split part.

Hello; I have a file consists of 4 columns separated by tab. The problem is the third fields. Some of the them are very long but can be split by the vertical bar "|". Also some of them do not contain the string "UniProt", but I could ignore it at this moment, and sort the file afterwards. Here is... (5 Replies)
Discussion started by: yifangt
5 Replies

5. 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

6. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: kmvinay
5 Replies

7. Shell Programming and Scripting

Print directory name along with their path

Can any one tell me that how can i print all directory with their path in a given parent directory. i.e. parent directory /home/usr/ Now this shoe directory may contain sevral directory /home/usr dir1/ dir1.1/ dir1.2/ dir2 dir2.1/ dir2.2/ ... (5 Replies)
Discussion started by: jadoo_c2
5 Replies

8. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

9. Shell Programming and Scripting

Split and print

I have a file with data such as: X Y Z 4 1,3,5,7, 4,6,8,10, A B C 3 2,3,4, 5,9,11, E F G 5 1,2,3,4,5, 8,9,10,11,12, Columns 1, 2 and 3 are descriptions. Column 4 tells how many numbers are in columns 5 and 6 What I'd like to do is split column 5 and column 6 by the "," and then... (3 Replies)
Discussion started by: dcfargo
3 Replies

10. AIX

split a filename and print to 2 different headings

I need help to split a filename 'a0crk_user:A0-B0123$#%test' into a0crk_user and A0-B0123 and print the output under 2 different columns namely User and Status. for eg. the output should like below: User Status ---- ------ a0crk_user A0-B0123 (3 Replies)
Discussion started by: mbak
3 Replies
Login or Register to Ask a Question