Sponsored Content
Full Discussion: Putting $$ before filename
Top Forums UNIX for Dummies Questions & Answers Putting $$ before filename Post 302889350 by bakunin on Thursday 20th of February 2014 05:08:25 AM
Old 02-20-2014
The problem - save for what Don Cragun already explained - "$$" is short for "the PID of the current process" and interpreted by the shell that way. YOu can test that with the following script:

Code:
#! /bin/sh
echo $$
sleep 9999999
exit 0

Start this script and from another terminal do:

Code:
ps -fp <PID>

substituting "<PID>" with the displayed number. You will see that the shell process has exactly this process number. (Stop the script with "CTRL-C" afterwards.)

So, even if you would manage to assign the value to such an ill-named variable you would have no possibility to retrieve it from there because any time you write "$$" it will be translated to the PID. If you want to simply have the "$$" in the output you can use "\" to escape the "$":

Code:
echo "\$\$filename"

I hope this helps.

bakunin

Last edited by bakunin; 02-20-2014 at 06:15 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Putting pC on network

How do I put a my PC with linux 7.0 on a class B network. Can someone give me info or text that will guide me? (1 Reply)
Discussion started by: Rush
1 Replies

2. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

3. Shell Programming and Scripting

joining multiple files into one while putting the filename in the file

Hello, I know how to join multiple files using the cat function. I want to do something a little more advanced. Basically I want to put the filename in the first column... One thing to note is that the file is tab delimited. e.g. file1.txt joe 1 4 5 6 7 3 manny 2 3 4 5 6 7 ... (4 Replies)
Discussion started by: phil_heath
4 Replies

4. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

5. Shell Programming and Scripting

Need help putting output on one line

Good afternoon, I have been searching the web, and these forums for help. I will try my best to explain the issue, and what my desired results are. I am doing queries in MYSQL, and need the output to be sent to a file. That file needs to have things with the same ID on the same line. To... (14 Replies)
Discussion started by: brianjb
14 Replies

6. Shell Programming and Scripting

putting two images together

Hi, I generated many figures in .png format (approximately 120). Right now I need to pair the figures on a single page so that the files with the same file name (i.e. jack) that end with .matrix.png are placed on the left and .cdt.png is on the right (so jack.matrix.png with jack.cdt.png... (6 Replies)
Discussion started by: kylle345
6 Replies

7. UNIX for Dummies Questions & Answers

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My Requirement: 1) There are some set of files in a directory like given below OTP_UFSC_20120530000000_acc.csv OTP_UFSC_20120530000000_faf.csv OTP_UFSC_20120530000000_prom.csv... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

8. Programming

to extract all the part of the filename before a particular word in the filename

Hi All, Thanks in Advance I am working on a shell script. I need some assistance. My code: if then set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator"\ "pam_account"; for i in 1 2 3 4 5 6 7 8;... (0 Replies)
Discussion started by: aealexanderraj
0 Replies

9. Shell Programming and Scripting

Other way aside from putting more PIPES (|)

I already manage to get the output that i want.. but wat if removing all the pipes and convert it 1 liner with less pipes. My command below can get the ouput that i want. i just want to remove the pipes or less pipes. #cat file1 us-west-2a running i-3397a421... (2 Replies)
Discussion started by: kenshinhimura
2 Replies

10. Hardware

Putting an old hd in a new computer

What are the steps you need to take when you put an old HD in a new computer? I just did this. Every time it makes it to the windows boot screen then restarts. I have a bunch of old engineering software that is not compatible with the newer versions of windows. I figured this out after I bought... (6 Replies)
Discussion started by: cokedude
6 Replies
LKBIB(1)                                                      General Commands Manual                                                     LKBIB(1)

NAME
lkbib - search bibliographic databases SYNOPSIS
lkbib [ -v ] [ -ifields ] [ -pfilename ] [ -tn ] key... It is possible to have whitespace between a command line option and its parameter. DESCRIPTION
lkbib searches bibliographic databases for references that contain the keys key... and prints any references found on the standard output. lkbib will search any databases given by -p options, and then a default database. The default database is taken from the REFER environment variable if it is set, otherwise it is /usr/dict/papers/Ind. For each database filename to be searched, if an index filename.i created by indxbib(1) exists, then it will be searched instead; each index can cover multiple databases. OPTIONS
-v Print the version number. -pfilename Search filename. Multiple -p options can be used. -istring When searching files for which no index exists, ignore the contents of fields whose names are in string. -tn Only require the first n characters of keys to be given. Initially n is 6. ENVIRONMENT
REFER Default database. FILES
/usr/dict/papers/Ind Default database to be used if the REFER environment variable is not set. filename.i Index files. SEE ALSO
refer(1), lookbib(1), indxbib(1) Groff Version 1.21 31 December 2010 LKBIB(1)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy