Sponsored Content
Top Forums Shell Programming and Scripting Puzzle: file name grepped from text file yields "no such file" Post 302491245 by josce on Thursday 27th of January 2011 04:27:01 AM
Old 01-27-2011
Cheers ! Adding 'eval' did the trick.


And thanks Citaylor for your explanation and refs.

Btw, ~ counts as a variable, I hadn't originally the sed bit to replace it with $HOME and the same issue was showing already.

Last edited by josce; 01-27-2011 at 05:33 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

2. Fedora

Piping output of "top" to a text file

I would like to pipe "top -n" to a text file, but I get an error: top: cannot open /dev/kmem kvm_open: Permission denied I am a non-root user. If I could find a way to get this type of output: "Memory: 2048M real, 1516M free, 4099M swap free" into a text file, I could further automate... (13 Replies)
Discussion started by: safraser
13 Replies

3. Shell Programming and Scripting

Identify high values "˙" in a text file using Unix command

I have high values (such as ˙˙˙˙) in a text file contained in an Unix AIX server. I need to identify all the records which are having these high values and also get the position/column number in the record structure if possible. Is there any Unix command by which this can be done to : 1.... (5 Replies)
Discussion started by: devina
5 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

6. Shell Programming and Scripting

"Content-type: text/html No input file specified." Only in CRON but not when executed directly

Hi gang, I have the following code inside a the file script.sh #!/bin/bash todaysdate=$(date --date='7 day' +'%d') todaysmonth=$(date +'%m') todaysyear=$(date +'%Y') yahoodatestring=$todaysyear$todaysmonth$todaysdate nicedate=$(date --date='5 day' +'%A') nice="$nicedate,... (2 Replies)
Discussion started by: phpchick
2 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. UNIX for Dummies Questions & Answers

Grep : Filter/Move All The Lines Containing Not More Than One "X" Character Into A Text File

Hi All It's me again with another huge txt files. :confused: What I have: - I have 33 huge txt files in a folder. - I have thousands of line in this txt file which contain many the letter "x" in them. - Some of them have more than one "x" character in the line. What I want to achieve:... (8 Replies)
Discussion started by: Nexeu
8 Replies

9. Shell Programming and Scripting

replace the contents of first column of file "X" with second Column of file "X" in file "Y"

Hi! I am having 02 files. In first file" X" I am having 02 Columns TCP-5100 Sybase_5100 TCP-5600 Sybase_5600 Second file "Y" for example-- :services ( :AdminInfo ( :chkpf_uid ("{A2F79713-B67D-4409-83A4-A90804E983E9}") :ClassName (rule_services) ) :compound ()... (12 Replies)
Discussion started by: shahid1632
12 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
GIT-FOR-EACH-REF(1)						    Git Manual						       GIT-FOR-EACH-REF(1)

NAME
git-for-each-ref - Output information on each ref SYNOPSIS
git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl] [(--sort=<key>)...] [--format=<format>] [<pattern>...] DESCRIPTION
Iterate over all refs that match <pattern> and show them according to the given <format>, after sorting them according to the given set of <key>. If <count> is given, stop after showing that many refs. The interpolated values in <format> can optionally be quoted as string literals in the specified host language allowing their direct evaluation in that language. OPTIONS
<count> By default the command shows all refs that match <pattern>. This option makes it stop after showing that many refs. <key> A field name to sort on. Prefix - to sort in descending order of the value. When unspecified, refname is used. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key. <format> A string that interpolates %(fieldname) from the object pointed at by a ref being shown. If fieldname is prefixed with an asterisk (*) and the ref points at a tag object, the value for the field in the object tag refers is used. When unspecified, defaults to %(objectname) SPC %(objecttype) TAB %(refname). It also interpolates %% to %, and %xx where xx are hex digits interpolates to character with hex code xx; for example %00 interpolates to (NUL), %09 to (TAB) and %0a to (LF). <pattern>... If one or more patterns are given, only refs are shown that match against at least one pattern, either using fnmatch(3) or literally, in the latter case matching completely or from the beginning up to a slash. --shell, --perl, --python, --tcl If given, strings that substitute %(fieldname) placeholders are quoted as string literals suitable for the specified host language. This is meant to produce a scriptlet that can directly be `eval`ed. FIELD NAMES
Various values from structured fields in referenced objects can be used to interpolate into the resulting output, or as sort keys. For all objects, the following names can be used: refname The name of the ref (the part after $GIT_DIR/). For a non-ambiguous short name of the ref append :short. The option core.warnAmbiguousRefs is used to select the strict abbreviation mode. objecttype The type of the object (blob, tree, commit, tag). objectsize The size of the object (the same as git cat-file -s reports). objectname The object name (aka SHA-1). For a non-ambiguous abbreviation of the object name append :short. upstream The name of a local ref which can be considered "upstream" from the displayed ref. Respects :short in the same way as refname above. In addition to the above, for commit and tag objects, the header field names (tree, parent, object, type, and tag) can be used to specify the value in the header field. Fields that have name-email-date tuple as its value (author, committer, and tagger) can be suffixed with name, email, and date to extract the named component. The complete message in a commit and tag object is contents. Its first line is contents:subject, the remaining lines are contents:body and the optional GPG signature is contents:signature. For sorting purposes, fields with numeric values sort in numeric order (objectsize, authordate, committerdate, taggerdate). All other fields are used to sort in their byte-value order. In any case, a field name that refers to a field inapplicable to the object referred by the ref does not cause an error. It returns an empty string instead. As a special case for the date-type fields, you may specify a format for the date by adding one of :default, :relative, :short, :local, :iso8601 or :rfc2822 to the end of the fieldname; e.g. %(taggerdate:relative). EXAMPLES
An example directly producing formatted text. Show the most recent 3 tagged commits: #!/bin/sh git for-each-ref --count=3 --sort='-*authordate' --format='From: %(*authorname) %(*authoremail) Subject: %(*subject) Date: %(*authordate) Ref: %(*refname) %(*body) ' 'refs/tags' A simple example showing the use of shell eval on the output, demonstrating the use of --shell. List the prefixes of all heads: #!/bin/sh git for-each-ref --shell --format="ref=%(refname)" refs/heads | while read entry do eval "$entry" echo `dirname $ref` done A bit more elaborate report on tags, demonstrating that the format may be an entire script: #!/bin/sh fmt=' r=%(refname) t=%(*objecttype) T=${r#refs/tags/} o=%(*objectname) n=%(*authorname) e=%(*authoremail) s=%(*subject) d=%(*authordate) b=%(*body) kind=Tag if test "z$t" = z then # could be a lightweight tag t=%(objecttype) kind="Lightweight tag" o=%(objectname) n=%(authorname) e=%(authoremail) s=%(subject) d=%(authordate) b=%(body) fi echo "$kind $T points at a $t object $o" if test "z$t" = zcommit then echo "The commit was authored by $n $e at $d, and titled $s Its message reads as: " echo "$b" | sed -e "s/^/ /" echo fi ' eval=`git for-each-ref --shell --format="$fmt" --sort='*objecttype' --sort=-taggerdate refs/tags` eval "$eval" AUTHOR
Written by Junio C Hamano <gitster@pobox.com[1]>. DOCUMENTATION
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org[2]>. GIT
Part of the git(1) suite NOTES
1. gitster@pobox.com mailto:gitster@pobox.com 2. git@vger.kernel.org mailto:git@vger.kernel.org Git 1.7.10.4 11/24/2012 GIT-FOR-EACH-REF(1)
All times are GMT -4. The time now is 01:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy