put working directory in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting put working directory in file
# 1  
Old 03-09-2011
put working directory in file

how to put pwd in my file
my working directory is /usr/my_dir
below my file

aaaaaa
bbbbbb

so output file become

/usr/my_dir
aaaaaa
bbbbbb
# 2  
Old 03-09-2011
Code:
printf %s\\n 1i "$PWD" . w q | ed -s file

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 3  
Old 03-10-2011
TRY

Code:
 (pwd;cat File_Name) > OUTPUT_Filename


Last edited by suresh.boddepu; 03-10-2011 at 02:13 AM..
This User Gave Thanks to suresh.boddepu For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Put -r is not working in SFTP

Hi Folks, I am trying to copy a directory along with sub-directories to SFTP server. I have connected to SFTP and tried to run the below command: sftp> get -r abc/* It is throwing the error Invalid flag -r Can you please let me know the ways to copy a directory from Local to SFTP ... (1 Reply)
Discussion started by: kirans.229
1 Replies

2. Programming

Java HTTP PUT Request/JSON Not Working But Using Python It Does ?

I have some code that I have been playing around with learning Java: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; ... (1 Reply)
Discussion started by: metallica1973
1 Replies

3. Shell Programming and Scripting

Foreach .gz file in a directory -- Not working

Hi, I am trying to add for loop in my code for all the .gz files in a directory. example code: for i in $PWD/input/*.dz do echo " file is :: $i " done This is not working as expectation and the output is : file is :: /home/IB/input/*.dz However, for i in $PWD/input/*... (5 Replies)
Discussion started by: IB_88
5 Replies

4. Shell Programming and Scripting

put file in different directory according to the filename

Dear all, I would like to know how to move the downloaded files in differenent directories according to the name of the file? i.e. P10120111201_122013M.jpg P10120120101_122013M.jpg P10120120201_122013M.jpg The first 4 charactors "P101" is the station name, 4-8 means year "2012",... (5 Replies)
Discussion started by: handsonzhao
5 Replies

5. UNIX for Dummies Questions & Answers

Cant find stdint.h? What directory do i put it in?

Hello everyone, I've got a C program that I'm trying to run through my unix shell but whenever i compile it using gcc (using "cc test.c"), it cannot find stdint.h. Right now, i have it in the same directory as the program I'm running, test.c. Any suggestions? (3 Replies)
Discussion started by: TeamUSA
3 Replies

6. Shell Programming and Scripting

Put header if file exists in a directory

Hi all, I will have to check a directory which is full of files. If any file more than 5 MB of space exists, write on it's head "Checked". Please help me. Thanks in advance! Deepak (5 Replies)
Discussion started by: naw_deepak
5 Replies

7. Shell Programming and Scripting

Script is not working when put in crontab

Hi there, this is part of my script: /usr/bin/cd /u01/oradata /usr/bin/cp `/bin/ls -1 . |grep -v "^DIMStemp01.dbf$" | grep -v "^DIMSts01.dbf$"|grep -v "^DIMStects01.dbf$"` /backup It's working fine when I manually run on telnet session. /bin/ls -1 . -- to list all the files inside... (2 Replies)
Discussion started by: *Jess*
2 Replies

8. Shell Programming and Scripting

Grep command is not working when put into cron

Hi, I worte a script which runs perfect when i execute it manually. But when i scheduled into cron the grep command alone is not working. the sample script, /usr/bin/grep FTP $subfile > /tmp/tfsrec.dat tfs=`echo $?` if then echo "FTP FOUND" else echo "FTP NOT FOUND" Where... (5 Replies)
Discussion started by: thiru_cs
5 Replies

9. UNIX for Dummies Questions & Answers

Change to a new working directory...

I need to CD to a particular directory to check log files and interface files. Instead of typing the path manually, is there a way of getting a script to change my working directory to the one I need? Currently I have a script that CD's to the directories I need but a soon as the script exits,... (5 Replies)
Discussion started by: jagannatha
5 Replies
Login or Register to Ask a Question