Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor ram recovery router screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
append contents of file to directory name

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
cgjoker's Avatar
Senior Member with 205 posts.
 
Join Date: Aug 2003
04-Sep-2003, 03:30 PM #1
append contents of file to directory name
How do I append contents from a file, example a date, to a directory name?
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
04-Sep-2003, 04:51 PM #2
could you be a little more specific or show us an example of what you want to do. I am not quite understanding the question.
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
08-Sep-2003, 09:31 AM #3
Code:
($:/tmp)=> ls -laoh
total 6
drwxrwxrwt   3 root  wheel  - 512B Sep  8 03:02 .
drwxr-xr-x  19 root  wheel  - 512B Sep  7 23:59 ..
drwxrwxrwt   2 root  wheel  - 512B Sep  8 00:01 .X11-unix
Give LS options... read man ls for more info
cgjoker's Avatar
Senior Member with 205 posts.
 
Join Date: Aug 2003
08-Sep-2003, 02:39 PM #4
why do you refer to the ls command?

if i have a file with the contents of '060703'

and id like to append those contents to a directory name how do i do this?

required output: 060703directory

thanks, cgjoker.
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
08-Sep-2003, 03:50 PM #5
Simple...

Code:
##  PARSER.SH By Mr Soup Guy

#!/usr/local/bin/bash
cat * > list.txt

for VAR in `cat list.txt`; do
echo "$VAR Was Found In Stuff.. Making Directory"
mkdir $VAR
done

rm list.txt
exit 0
just place it in some script directory.. not inside your working directory..

run as

$../parser.sh .

you might also want to research about shell scripting and read the man pages on sed and awk .. you might need to customize the script a little to fit your needs.

Last edited by soup4you2 : 08-Sep-2003 04:02 PM.
cgjoker's Avatar
Senior Member with 205 posts.
 
Join Date: Aug 2003
10-Sep-2003, 04:18 PM #6
thanks.. but it looks like your program only renames the directory to what is in the file... (which is good), but I need it to also append the contents to an existing directory name.

so, say date was the contents of list.txt...

the directory which id want renamed was called olddir,

the new directory would be:

dateolddir

thanks.
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
10-Sep-2003, 04:31 PM #7
i'm having a really hard time fully understanding what you want.. so here's a Excelent resource to learning bash scripting..

http://neworder.box.sk/bash.tutor.php
cgjoker's Avatar
Senior Member with 205 posts.
 
Join Date: Aug 2003
11-Sep-2003, 04:54 PM #8
SOUP....

i figured out how to do it... here is what i was trying to do fyi.

pretty simple once i took soom time to think about it.

DIR2=final_file2
DIR6=final_file6
DIRIN=in_data

cat filedate.dat > list.txt

for VAR in `cat list.txt`;

do

mv $DIR2 $DIR2$VAR
mv $DIR6 $DIR6$VAR
mv $DIRIN $DIRIN$VAR

mkdir $DIR2
mkdir $DIR6
mkdir $DIRIN

cp ./$DIR2$VAR/*.dct ./$DIR2/.
cp ./$DIR6$VAR/*.dct ./$DIR6/.
cp ./$DIRIN$VAR/*.dct ./$DIRIN/.


done
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
12-Sep-2003, 08:58 AM #9
ahhh now i see.... Glad to see you got it `werkin...
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 12:04 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.