Sponsored Content
Full Discussion: Bash join script not working
Top Forums Shell Programming and Scripting Bash join script not working Post 302577685 by Nostyx on Tuesday 29th of November 2011 03:25:22 PM
Old 11-29-2011
Bash join script not working

So i'm currently working on a project where I'm attempting to display information of users from the /etc/passwd file and also another information file holding addition information about users.

Problem is I've been trying to join the two files together and have all of the information about each user in 1 file on 1 line for each user but it doesn't want to work for me.
Both files are delimited by colons.

note: information here is made-up .

Code:
$cat AdditionalInfo
 Usr1:Jill Smith:123 Sunset Avenue:1990:2001
 Usr2:Jack Bloggs:321 Sunrise Street:1989:2010
 ect....

/etc/passwd has lots more users than the few that are in the Additional information file and i only need the info from /etc/passwd for those records.

So far all my attempts of joining the files end with either no output, or only the output from the additionalinfo file.

Code:
$join -t: AdditionalInfo /etc/passwd

gives nothing.

if anyone knows why this doesn't work and can offer a solution it would be greatly appreciated.

Desired output would be

Usr1:Jill@mail.com:123 Sunset Avenue:1990:2001:x:1000:1000:Jill Smith:/home/admin/Usr1:/bin/bash
Usr2:Jack@mail.com:321 Sunrise Street:1989:2010:x:1001:1001:Jack Bloggs:/home/admin/Usr2:/bin/bash
-

Last edited by Nostyx; 11-29-2011 at 04:32 PM.. Reason: desired output.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

join not working

I was trying to merge the following two example files using their first field: join -1 1 -2 1 file1 file 2 but nothing is produced. The expected result should be: rs1005152 7 q21.3 3 It appears that the length of the first field in file1 is causing the problem. Any suggesting on how to... (12 Replies)
Discussion started by: gamma_user
12 Replies

2. Shell Programming and Scripting

Simple BASH script not working?

So I need a script that does the following: If a certain user is logged in Run `command` Else Echo “incorrect user” This is my first stab...which doesn't work: #!/bin/bash X="user=`ls -l /dev/console | cut -d " " -f 4`" Y="foobar" echo $X echo $Y (4 Replies)
Discussion started by: doubleminus
4 Replies

3. Shell Programming and Scripting

Moving old files bash script - not working properly

I'm trying to write a script that moves data that's older than 2 weeks to a different place. It works well, EXCEPT, that when the script hits a file within a directory inside the working directory, it will move it to the root of the destination directory instead of putting it in the correct... (1 Reply)
Discussion started by: ugolee
1 Replies

4. Shell Programming and Scripting

bash script for ftp-upload is not working

Hello everyone, sorry for the title, most of you must getting sick of reading something like this, but I haven't found a solution, although I found many threads according to it. I'm working on a bash script that connects to a network printer with ftp where I want to upload a pdf created... (3 Replies)
Discussion started by: le_mae
3 Replies

5. Shell Programming and Scripting

sed not working in a bash script

Hi friends, I have two files - input and commands I want to read the input and replace a value in it with the contents in commands. My script is like this. Instead of printing the value in the commands file, it is simply printing $cmd in the output file. Any pointers are highly... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

6. Shell Programming and Scripting

Join not working for comparision

Hi All, I have 2 files where the first column of both the files have to be compared and if they match the first six columns of the first file to be extracted in the output file. Format of files : File1 : ${SHTEMP}NPBR5.XTR.tmp S00016678|129|7|MPF|20090106|E... (3 Replies)
Discussion started by: nua7
3 Replies

7. UNIX for Dummies Questions & Answers

Join not working

Hi all, I'm trying to use the join command to merge two files, but it's not finding lots of the matches. I have three files in total: File A: 31_77 34_46 72_61 85_10 85_23 110_33 144_45 154_25 154_90 170_5 170_44 217_63 255_19 333_20 333_23 333_32 (2 Replies)
Discussion started by: HEP
2 Replies

8. Shell Programming and Scripting

Expect not working inside my Bash script

I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows: #!/bin/bash HOST=$1 /usr/bin/expect -c " spawn ssh -i /root/.ssh/id_rsa root@$HOST expect -exact "Enter... (3 Replies)
Discussion started by: John Wilson
3 Replies

9. Shell Programming and Scripting

Aliases NOT working inside bash shell script

i have defined a function ln_s() for customizing the ln command in script1.sh. more script1.sh echo "Starting Execution" ./script2.sh echo "End of Execution" ln_s(){ ] && return ln -s "$1" "$2" } My script1.sh executes another script2.sh which has the following entry more script2.sh... (12 Replies)
Discussion started by: mohtashims
12 Replies

10. Programming

Best way to get a bash script working in C

Ahoy friends. Currently i got a bash script running to manage my minecraft servers. All of them are stored in /home/minecraft_servers directory. Using my script im able to start a server (e.g. ./minecraft start ftb_continuum) because server name and server name are the same.(e.g.... (2 Replies)
Discussion started by: Knogle
2 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a filename containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 10:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy