Simple list question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple list question
# 1  
Old 04-25-2012
Simple list question

Hi,

Can someone tell me how to do this...

I want to concatenate a list of files with a ':' using the find command...

I have tried

Code:
find ${dir} -type f -print | sed 's/$/:/g'

but what this does is only append a ':' to the end of the file instead of removing the new line and concatenating the list... Smilie preferably a one liner as currently I am having loop through a list of files using the find command and appending the file to a variable followed by a ':' which is slow...
# 2  
Old 04-25-2012
Code:
 
find  ${dir} -type f -print | while read a; do echo -n "$a:"; done

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 04-25-2012
Or maybe with:
Code:
find ${dir} -type f -print | awk 1 ORS=:

This User Gave Thanks to Franklin52 For This Post:
# 4  
Old 04-25-2012
Quote:
Originally Posted by itkamaraj
Code:
 
find  ${dir} -type f -print | while read a; do echo -n "$a:"; done

Excellent! Thanks...knew it would be simple... Smilie
# 5  
Old 04-25-2012
Hi,

another way:
Code:
VAR=$(find ${dir} -type f -exec echo  \"{}\"\: \; )

This User Gave Thanks to pokerino For This Post:
# 6  
Old 04-25-2012
try this Smilie [ GNU find ]
Code:
$ find ${dir} -type f -printf "%p:"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

2. Shell Programming and Scripting

Simple question 3

Here I am again~~ I am studying the storing function and dot command. But I found I couldn't load a stored function from a file. This is my command-line and script: $ ls -lsa Total 5 0 drwxr-xr-x+ 1 Administrator None 0 May 9 14:44 . 0 drwxr-xr-x+ 1 Administrator None 0 May 9 10:38 .. 4... (4 Replies)
Discussion started by: franksunnn
4 Replies

3. UNIX for Dummies Questions & Answers

A Simple Question

Hi All, I am new to Unix , I have entered 'cd w' in command prompt and pressed tab key , A tab space is generated instead of listing the folders or files that starts with 'W' . What should i do to get it working:confused: Thanks, Deepak (2 Replies)
Discussion started by: Deepakkumard
2 Replies

4. Shell Programming and Scripting

Simple ls question

i am doing ls -la in the out put , first line is as total 41621 What is this total? (2 Replies)
Discussion started by: Saurabh78
2 Replies

5. Programming

Simple C question... Hopefully it's simple

Hello. I'm a complete newbie to C programming. I have a C program that wasn't written by me where I need to write some wrappers around it to automate and make it easier for a client to use. The problem is that the program accepts standard input to control the program... I'm hoping to find a simple... (6 Replies)
Discussion started by: Xeed
6 Replies

6. UNIX for Dummies Questions & Answers

Very simple question

I'm new to unix commands and am wondering how you could create a page with html tags in it. echo "<b>Test</b>" > test.html doesn't work because of the tags. How would I do this. (4 Replies)
Discussion started by: roger19
4 Replies

7. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

8. UNIX for Dummies Questions & Answers

Simple Question

Can anyone tell me if there is a way to remove the encryption from Data CDs by UNIX? Or does anyone know of a program that can remove the encryption? I would much appreciate it! Thanks, -Peaves (2 Replies)
Discussion started by: Peaves
2 Replies

9. UNIX for Advanced & Expert Users

Simple Question

Friends, I did following exercise $ echo '' > test $ od -b test $ echo "">test $ od -b test $echo > test $od -b test Every time I got the following output 0000000 012 0000001 But 012 is octal value for new line character . Even though there is no apperent new line character... (6 Replies)
Discussion started by: j1yant
6 Replies

10. UNIX for Dummies Questions & Answers

Simple question?

I've been a Linux user for quite some time, started out with Red Hat and Mandrake, and just recently moved to Slackware linux.... my question is this: Is there a big difference between Linux and Unix? If so, what? I was just looking at Sun's Solaris 8 thats free for download on Intel... (5 Replies)
Discussion started by: Cuthbert
5 Replies
Login or Register to Ask a Question