Sponsored Content
Top Forums Shell Programming and Scripting Awk displays file name twice (?!) Post 302497221 by alan on Wednesday 16th of February 2011 03:25:44 PM
Old 02-16-2011
Awk displays file name twice (?!)

Greetings.

I have files that contains eleven fields in the file name. Each file has a specific meaning. My job is to list each file name and load the info into a database table for reporting.

My awk code does this (files have VER suffix):

Code:
    find . -name "*.VER" -exec ls '{}' ';' -printf %f\\t | awk -F"~" '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10"\t"$0}' > somefile.tab

It works fine except that it does something weird with the file name ($0): it repeats it like so (the 2 last fields from the right):

Code:
    RRR1	PRE	DTV_PREP	PREP05	JGM15453.	26	P	H23-600	029416589165	20110216	RRR1~PRE~DTV_PREP~PREP05~JGM15453.~26~P~H23-600~029416589165~20110216~090353.VER	./RRR1~PRE~DTV_PREP~PREP05~JGMDTV269~33~P~H21-200~029384120357~20110216~091829.VER

What am missing here? Any ideas?

Thanks for your input.

---------- Post updated at 12:25 PM ---------- Previous update was at 12:11 PM ----------

I removed " -printf %f\\t " and replaced $0 with $filename. It works now but display "./" right before the filename. How can remove these two leading characters?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Dual Displays

I have a TV and a monitor hooked up to my box. Right now the system is displaying all the information on the TV instead of the monitor, obviously I want to switch this, as the TV is very impracticle for everything other than watching movies. I thought I remembered a command I used to use that... (2 Replies)
Discussion started by: Synbios
2 Replies

2. HP-UX

Dual Displays HP-UX 10.20

Hello All! Where I work we have C3600's that have a video cards that have both DVI and Regular RBG type monitor ports on them. My question is: is it possible to spread my desktop across two monitors that are plugged into the one card much like you can do with NVIDIA software like NVIEW for... (0 Replies)
Discussion started by: giftedone
0 Replies

3. AIX

who -r displays no output

Hello. I have an AIX machine at 6100-00. We had some strange activity since filling up /tmp. One symptom is that who -r displays no output. It doesn't hang just no output is displayed. We are going to boot the machine, but prior to that I'd like to dig a bit to see what may be causing the... (0 Replies)
Discussion started by: maficdan
0 Replies

4. UNIX for Dummies Questions & Answers

Creating a file that contains output from a command, and then displays itself

hey, I'm trying to create the command that will create a file named user.txt that contains the output of the command cut -d: -f1,5 /etc/passwd, and displays itself afterwards. I don't know how to bridge cat > user.txt with cut -d: -f1,5 /etc/passwd, or how display it afterwards. Any help would... (2 Replies)
Discussion started by: raidkridley
2 Replies

5. UNIX for Dummies Questions & Answers

ls -l displays size in KB, MB, GB?

Hi, ls -l displays the long listing of a file in 8 fields. Query: ------ Does ls -l display the filename size in KB or MB or GB? -rwxrwxr-x 1 xx dba 655 May 22 06:27 time Here 655 is KB or MB or GB? Many thanks. (2 Replies)
Discussion started by: venkatesht
2 Replies

6. Solaris

ls -l displays output with an error

when i use ls command it works normal but when i using additional parameter with ls like ls -l , ls -a... it shows a error followed by the output. # ls -l ./hgfs: Operation not applicable total 12861 -rw-r--r-- 1 root root 0 Jun 1 21:12 1 drwxr-xr-x 2 root root ... (4 Replies)
Discussion started by: chidori
4 Replies

7. UNIX for Dummies Questions & Answers

script works well but displays " line 6: =: No such file or directory"

strange :) can you tell why?:cool: #!/bin/bash echo " enter your age " read age if ; then echo " you do not have to pay tax " elif ]; then echo " you are eligible for income tax " else echo " you dont have to pay tax " fi (3 Replies)
Discussion started by: me.
3 Replies

8. UNIX Desktop Questions & Answers

Cat/tac displays nothing but vi does

Hi, Today i have seen a file which shows nothing when i use cat/tac. But when i use vi it displays a single line at the top. There are no other lines. I am curious why cat/tac doesn't display that line and only vi does? Any thoughts? Thanks in advance, (1 Reply)
Discussion started by: pandeesh
1 Replies

9. Shell Programming and Scripting

Bash $(...) DISPLAYS EVERY COMMAND

I use things like this a lot in ksh and bash, but lately bash has been printing the command for every loop: ... | while read f do if then echo Differ "$f" fi done How to prevent this? (5 Replies)
Discussion started by: DGPickett
5 Replies
appmgr(8)																 appmgr(8)

NAME
appmgr - Tool to manage applications and platforms SYNOPSIS
appmgr list [--no-versions] appmgr add NAME DESC [--hr=no | --hr=fine | --hr=coarse] [--beta] [--weight=NUM] [--target_nresults=NUM] appmgr delete NAME [--version=VER] [--platform=NAME] [--plan_class=NAME] appmgr update NAME [--hr=no | --hr=fine | --hr=coarse] [--beta | --no-beta] [--weight=NUM] [--target_nresults=NUM] [--user_friendly_name=DESC] [--min_version=VER] [--deprecated | --no-deprecated] appmgr update_appver NAME [--version=VER] [--platform=NAME] [--plan_class=NAME] [--deprecated | --no-deprecated] [--min_core_version=VER] [--max_core_version=VER] appmgr list_platform [--short] appmgr add_platform NAME DESC appmgr delete_platform NAME [--force] appmgr update_platform NAME [--user_friendly_name=DESC] [--deprecated | --no-deprecated] appmgr add_standard_platforms appmgr {-h | --help} DESCRIPTION
appmgr is a tool to manage platforms, applications and application versions from the command-line. Note: application refers to data in the app table; application version refers to data in the app_version table and in the file system. COMMANDS
The generic syntax is: appmgr COMMAND [command arguments] Note that command-specific options must came after the command, never before. Here is a short list of the available commands. The follow- ing sections describe the commands in detail. list List the installed applications and application versions. add Add a new application. delete Delete an application or application version. update Update the properties of an application. update_appver Update the properties of an application version. list_platform List the platforms known to the project. add_platform Add a new platform. delete_platform Delete a platform. update_platform Update the properties of a platform. add_standard_platforms Add all standard platforms to the project. LIST List the installed applications and application versions, together with any non-default properties (beta, deprecated, min. core version etc.). If the --no-versions option is specified, then the list of application versions is omitted and just the application definitions are listed. ADD Add a new application. NAME is the short name of the application as used in the file system. DESC is the user-friendly name that is dis- played to users. The following options can also be specified: --hr=no, --hr=fine, --hr=coarse Set the homogeneous redundancy class. no means all hosts are equivalent, fine means fine-grained classification of 80 classes, coarse means coarse classification of 4 classes. --beta Indicate that this is application is in beta testing. Users can select if they are willing to test applications marked as beta in their preferences; see the wiki section "Beta-test applications" about how to enable this on the web interface. --weight=NUM Specify the weight of this application if the feeder is run with the -allapps option. NUM is a floating-point value, the default is 1. --target_nresults=NUM Set the number of replicas when an otherwise unreplicated work unit is sent to a host that is not trusted. See the wiki section "Adaptive replication" for details. DELETE Delete applications or application versions. This command deletes both the database records and the files under the download and apps di- rectories, so use with care. The following options can be specified: --version=VER Select only application versions with the version number VER. The version number must be specified as major.minor. --platform=NAME Select only application versions for the platform NAME. --plan_class=NAME Select only application versions having the plan class NAME. If more than one of the options --version, --platform and --plan_class are specified, then only application versions matching all the cri- teria are deleted. If none of these options are specified, then the application is also deleted. Note that if one or more of these options are specified then the application is not deleted even if there are no more application versions remaining. UPDATE Update the properties of an application. The following properties can be modified: --hr=no, --hr=fine, --hr=coarse Set the homogeneous redundancy class. no means all hosts are equivalent, fine means fine-grained classification of 80 classes, coarse means coarse classification of 4 classes. Warning Do not change the homogeneous redundancy class while there are jobs in progress! --beta Indicate that this is application is in beta testing. Users can select if they are willing to test applications marked as beta in their preferences; see the wiki about how to enable this on the web interface. --no-beta Indicate that the application is no more in beta testing. --weight=NUM Specify the weight of this application if the feeder is run with the -allapps option. NUM is a floating-point value, the default is 1. --target_nresults=NUM Set the number of replicas when an otherwise unreplicated work unit is sent to a host that is not trusted. See the wiki article on "Adaptive replication" for details. --user_friendly_name=DESC Update the user-friendly description of the application. --min_version=VER Set the min. version of the application that the scheduler accepts. This is checked only if the client uses the anonymous platform. The version number must be specified as major.minor. --deprecated Indicate that the application is deprecated. The feeder will then ignore this application when looking for new work. --no-deprecated Remove the deprecation mark from the application. UPDATE_APPVER Update the properties of an application version. The version(s) to operate on can be specified with the --version, --platform and --plan_class options, as described at the DELETE command. The following properties can be modified: --min_core_version=VER Set the min. version of the core client that is required to run this application version. The version number must be specified as major.minor. The 3rd component (the patch level) of the core client version is ignored. --max_core_version=VER Set the max. version of the core client that is allowed to run this application. Note that the scheduler ignores this setting cur- rently. --deprecated Indicate that the application version is deprecated. The feeder will then ignore this version when looking for new work. --no-deprecated Remove the deprecation mark from the application version. LIST_PLATFORM List the platforms known to the project. If the --short option is specified, then only the short names of the platforms are listed. ADD_PLATFORM Add a new platform. NAME is the short name of the platform that is used in the scheduler requests. DESC is the user-friendly name that is displayed to users. DELETE_PLATFORM Delete a platform. If the --force option is specified, the command deletes all application versions for this platform. Otherwise, if there are such application versions, the command will fail. UPDATE_PLATFORM Update the properties of a platform. The following properties can be modified: --user_friendly_name=DESC Update the user-friendly description of the platform. --deprecated Indicate that the platform is deprecated. The feeder will then ignore this platform when looking for new work. --no-deprecated Remove the deprecation mark from the platform. ADD_STANDARD_PLATFORMS Add all the standard platform definitions to the database that do not exist yet. August 27, 2009 appmgr(8)
All times are GMT -4. The time now is 05:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy